Git Product home page Git Product logo

pixoo-homeassistant's Introduction

Divoom Pixoo 64 Home Assistant Integration

hacs_badge Donate python badge last commit

Custom component for easy use of a Pixoo64 within Home Assistant. With this integration you have the possibility to display different designs and personalize them with information from the Home Assistant. For example, you can use this integration to display several texts {{ templates }} and images on one page. You can also use this integration to determine how long you want to see a page, e.g. you can set the page to change every 15 seconds. In addition, you also have a light entity for switching the display on and off or changing the brightness. Last but not least, you can create automations with which you can use certain triggers to display the pages that are available to you as a push.

Installation

  1. Install this integration with HACS (adding repository required), or copy the contents of this repository's custom_components/divoom_pixoo directory into your custom_components/divoom_pixoo directory.

    Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

  2. Restart Home Assistant.

  3. Go to Settings / Integrations and add integration "Divoom Pixoo 64".

    Add Integration to your Home Assistant instance.

  4. Please select a discovered Pixoo 64 device from the list or select 'Manual IP' to manually enter the device's IP yourself.

Configuration

Base

Settings > Devices > Divoom Pixoo > Configure

IP address of the device: discovered or manually entered IP

Scan interval (in seconds): The amount of time a page is displayed

List of pages in YAML: See below (Optional)

Page Types & Configurations

Each page type will have configuration options unique to it. All configs should be written using YAML If you're new to this integration, we recommend starting with the components page type.

In the YAML config, all pages are nested under - page_type: XXX When setting the default configuration. Multiple pages can be set. These will be rotated through using the "duration" tag, or by default the time set in "scan interval".

YAML Layout example

- page_type: channel
  id: 0
- page_type: clock
  id: 182

In addition, all page types can be dynamically set to Enable/Disable based on HA entities.

Config Options required Default Values
enabled No true bool or {{ template }} #expects state = 'true', 'yes', 'on' or '1'
- page_type: PAGE_TYPE
  enabled: "{{ states.input_boolean.YOURS.state }}"

You can also set the duration of a page in seconds. This will override the scan interval set in the device settings.

Config Options required Default Values
duration No (The Scan Interval) integer/float in seconds
- page_type: PAGE_TYPE
  duration: 10

Note

The enabled tag and duration tag only apply when used in the configuration. Therefore, they won't word in the service.

Page: Components

A components page turns your Pixoo into your canvas! You can tie multiple text/image configs to a single page.

- page_type: components
  components:
    - type: text
      #[text config]
    - type: text
      #[text config]
    - type: image
      #[image config]
    - type: rectangle
      #[rectangle config]
    - type: templatable
      #[templatable config]

Note

Position X,Y coordinates will need to be manually configured for each component type

XY Positioning

Component Configurations

-type: [ text | image | rectangle ]

Component: Text

Config Options required Default Values
position Yes The text position on a XY axis at 64x64 pixel
content Yes Your message! {{ templates }} and Newline Support in text
font No pico_8 Fonts
color No white [R, G, B] or Colors

Example

    - type: text
      position: [0,0]
      content: Welcome Home!

Component: Image

Config Options required Default Values
position Yes The text position on a XY axis at 64x64 pixel
image_path Yes(pick one) image path like /config/img/haus.png
image_url Yes(pick one) image url like template {{ entity image }} or https://raw.githubusercontent.com/gickowtf/pixoo-homeassistant/main/images/fuel.png
image_data Yes(pick one) image data in base64. Convert images here.
height No If none is selected, the image will be at it's original size. If one is selected, it will become the longest side. Proportional
width No If none is selected, the image will be at it's original size. If one is selected, it will become the longest side. Proportional
resample_mode No box box, nearest, bilinear, hamming, bicubic, lanczos

Example

    - type: image
      position: [5,5]
      image_path: /config/image/haus.png
      resample_mode: box
      height: 64

Component: Rectangle

Config Options required Default Values
position Yes The text position on a XY axis at 64x64 pixel
size Yes final size of the rectangle. looks like [width, height]
color No [R, G, B] or Colors
filled No boolean

Example

    - type: rectangle
      position: [20,  20]
      size: [10,  10]
      color: yellow
      filled: "{{ states.input_boolean.YOURS.state }}"  #optional

Component: Templatable

Config Options required Default Values
template Yes jinja2 template

Example

    - type: templatable
      template: >-
        {% set entities = [["input_boolean.sw1", "input_boolean.sw2"],
        ["input_boolean.sw2"]] %} {% set origin = [1, 62] %}

        {% set output = namespace(list=[], position_x = origin[0], position_y =
        origin[1]) %} {% for entity_group in entities -%} {# {%- if loop.first
        %}The {% elif loop.last %} and the {% else %}, the {% endif -%} #}

        {% for entity in entity_group -%} {# {%- if loop.first %}The {% elif
        loop.last %} and the {% else %}, the {% endif -%} #} {% set entity_state
        = states(entity) %}

        {## Select the color ##} {% if entity_state=="off" or
        entity_state=="not_home" or entity_state == "standby" %} {% set
        color="red" %} {% elif entity_state=="on" or entity_state=="home" %} {%
        set color="green" %} {% elif entity_state=="playing" or
        entity_state=="idle" or entity_state=="paused" %} {% set color="blue" %}
        {% else %} {% set color="white" %} {% endif %}

        {% set component = {"type": "rectangle", "size": [1,1], "color": color,
        "position": [output.position_x, output.position_y]}%}

        {## Make next pixel 2px higher ##} {% set output.position_y =
        output.position_y - 2 %} {## Add to the output list##} {% set
        output.list = output.list + [component] %}

        {%- endfor %} {## Make next pixel 2px to the right ##} {% set
        output.position_x = output.position_x + 2 %} {## reset y ##} {% set
        output.position_y = origin[1] %} {%- endfor %} {{output.list}}

Variables (Optional) (Only for the components page)

If you wish for easier sharing of your custom component pages, you can define variables in the variables tag. These can then be used in any template.

Note

The variables tag is not supported in the service call. For those, you have to use Home Assistant's variables feature (with automations/scripts)

Example usage:

- page_type: components
  variables:
    power: "{{ states('input_number.power') }}"
    storage: "{{ states('input_number.storage') }}"
  components:
    - type: image
      image_path: /config/custom_components/divoom_pixoo/img/sunpower.png
      position: [2,1]
    - type: text
      content: "{{ power }}"
      color: "{{ [255,175,0] if power|int >= 1 else [131,131,131] }}"
      font: gicko
      position: [17,8]
    - type: image
      image_path: "{{ '/config/custom_components/divoom_pixoo/img/akku80-100.png' if storage|int >= 80 else '/config/custom_components/divoom_pixoo/img/akku60-80.png' if storage|int >= 60 else '/config/custom_components/divoom_pixoo/img/akku40-60.png' if storage|int >= 40 else '/config/custom_components/divoom_pixoo/img/akku20-40.png' if storage|int >= 20 else '/config/custom_components/divoom_pixoo/img/akku00-20.png'}}"
      position: [2, 17]
    - type: text
      content: "{{ storage }}"
      color: "{{ [255,0,68] if storage|int <= 0 else [4,204,2] }}"
      font: gicko
      position: [17, 18]

Page: gif

Animated GIFs

  1. Download the gif on your computer.
  2. Resize your gif to 16x16, 32x32 or 64x64. I know some websites say it's 64x64, but it has to actually be 64x64. You can resize gifs on multiple websites. Here's an example. (You only have to select manually the width and height of the size down the page).
  3. Re-download the gif.
  4. Re-upload the gif. You can use many image services like this one. (Make sure you use the gif file's link, and not the "gif viewing page". You can get that by right-clicking the gif on the website, and then clicking "Copy Image Link". The link in your clipboard probably now ends in .gif, like your file. (Although this might not be 100% the case.))
Config Options required Default Values
gif_url Yes URL

Example:

- page_type: gif
  gif_url: https://i.ibb.co/tKnvLs2/ezgif-5-30ff95e9ca.gif

Page: Channel

In Divoom app you can set three different custom channels which you can select here.

Note

The Divoom custom channel pic cycle rate must be set in the app itself.

  • Channel 1 = id: 0
  • Channel 2 = id: 1
  • Channel 3 = id: 2
Config Options required Default Values
id Yes Integer

Example:

- page_type: channel
  id: 0

Page: Clock

In Divoom app, there's a big list of clocks that you can set to your device.

- page_type: clock

Config Options required Default Values
id Yes Clock ID list of clock ID's

Example:

- page_type: clock
  id: 182

Alternative Method to find ClockFace ID's

  1. Navigate to settings > integrations > Divoom Pixoo 64
  2. Activate debug logging
  3. Open the Divoom app on your smartphone and select your preferred ClockFace.
  4. As soon as this is displayed on your Pixoo64, you will find "Device Data" in the log and then "CurClockId".
  5. The CurClockId is the number you were looking for.

Page: Visualizer

This adds the visualizer page to the integration.

Config Options required Default Values
id Yes Clock (visualizer) ID

The id starts at zero and it represents the clocks from top left to bottom right as can be seen in the app.

Example:

- page_type: visualizer
  id: 2

Page: PV

Photovoltaic - PV is a pre-designed page. The icon changes depending on the battery capacity and the font color changes from red to green Helper entities may have to be used here

- page_type: PV
  enabled: "{{ states.input_boolean.YOURS.state }}"  #is only displayed if the state = 'true', 'yes', 'on' or '1'
  power: "{{ states.sensor.YOUR_SENSOR.state }}"
  storage: "{{ states.sensor.YOUR_SENSOR.state }}"
  discharge: "{{ states.sensor.YOUR_SENSOR.state }}"
  powerhousetotal: "{{ states.sensor.YOUR_SENSOR.state }}"
  vomNetz: "{{ states.sensor.YOUR_SENSOR.state }}"
  time: "{{ now().strftime('%H:%M') }}"

Page: Progress Bar

Pre-designed page with a progress bar, for example, for the status of the dishwasher or for the charging status of the car

- page_type: progress_bar

Config Options required Default Values
header Yes string or use {{ template }} e.g. Dishwasher
progress Yes integer or use {{ template }}
footer Yes string or use {{ template }} e.g. Date
bg_color No blue use "[R, G, B]" or Colors
header_offset No 2 integer
header_font_color No white use "[R, G, B]" or Colors
progress_bar_color No red use "[R, G, B]" or Colors
progress_text_color No white use "[R, G, B]" or Colors
time_color No grey use "[R, G, B]" or Colors
footer_offset No 2 integer
footer_font_color No white use "[R, G, B]" or Colors

Example:

- page_type: progress_bar
  enabled: >-
  {% if is_state('sensor.DISHWASCHER_STATE', 'Run') %} true {% else %} false {% endif %}
  header: DISHWASHER
  progress: "{{ states.sensor.DISHWASHER_PROGRESS.state }}"
  footer: ANY FOOTER
  header_font_color: "[255, 255, 255]"

Page: Fuel

Special Page for Gas Station Pricing. Helper entities may have to be used here

- page_type: fuel


Config Options required Default Values
title Yes string - can use {{ template }} e.g. Gas Station Name
name1 Yes string - can use {{ template }} e.g. fuel type
price1 Yes use {{ template }} e.g. fuel price
name2 Yes string - can use {{ template }}
price2 Yes use {{ template }}
name3 Yes string - can use {{ template }}
price3 Yes use {{ template }} eg. fuel price
status Yes string - can use {{ template }} Any extra field in my case an opening status
font_color No white "[R, G, B]" or Colors
bg_color No yellow (255, 230, 0) "[R, G, B]" or Colors
price_color No white "[R, G, B]" or Colors
title_color No black "[R, G, B]" or Colors
stripe_color No font_color "[R, G, B]" or Colors
title_offset No 2 integer used to center the text

Example of the image:

- page_type: Fuel
  enabled: "{{ states.input_boolean.YOURS.state }}"
  title: Classic
  name1: Diesel
  price1: "{{ states.sensor.diesel.state }}"
  name2: Super
  price2: "{{ states.sensor.super.state }}"
  name3: E10
  price3: "{{ states.sensor.e10.state }}"
  status: >-
  {% if is_state('binary_sensor.status', 'on') %} Offen {%
  else %} Geschlossen {% endif %}
  title_offset: "10"
  font_color: "[255, 255, 255]"

Newline

Newline Support in content: example:

content: |-
text 1
{{ states.*.state }}

There is no limit to the maximum newlines except for 64 pixels ;)


Services

Service: Send a page to Divoom Pixoo (show_message) Push Notification

You can use it for Push Notifications. Trigger with anything! Call it with the Service "Divoom Pixoo 64: Send a page to Divoom Pixoo".

You can input in the Page Data field the data of one page in the normal YAML format. It can be anything!

Note

This is intended to be a temporary override of your default configuration. Any Enable/disable lines will not be respected here.

Some examples of Page Data:

page_type: clock
id: 182

or

page_type: components
components:
  - type: text
    position: [10,  0]
    content: 2 github/gickowtf
    font: gicko
    color: [255,  0,  0]
  - type: image
    image_path: /config/img/haus.png
    position: [30,  30]

Service: Play a Buzzer

Play the buzzer on the Divoom Pixoo. Beware that this maybe could damage the device. Use at your own risk.

Buzzing Time per cycle. in milliseconds default: 500 milliseconds

The working time of the buzzer per cycle. The buzzer will not buzz continuously; it will go on and off in cycles (duration in-between not controllable).

Idle Time per cycle in milliseconds default: 500 milliseconds

Idle time of the buzzer per cycle.

Total Time in milliseconds default: 3000 milliseconds

The total time the buzzer will be working.


Service: Restart the Divoom Pixoo

Restart the Divoom Pixoo device. (It has a little bit of delay. Be patient.)



Templates

As mentioned above, templates allow you to bring Entity states and attributes directly to your Pixoo! (eg. Temperature, brightness, presence, entity on/off). They can be used in most settings in the integration. For a deep dive see https://www.home-assistant.io/docs/configuration/templating/ or even https://jinja.palletsprojects.com/en/latest/templates/ (The language behind templates)

You can find the entity ID in HA under Developer > States (Although you shouldn't need this.)

Example usages of templates

Report Raw Sensor Readings

Binary sensors are the easiest to start with, as they simply live in one of two states, On or Off.

- page_type: components
  components:
    - type: text
      position: [0,0]
      color: white
      content: "Motion-FL1: {{ states('binary_sensor.MotionDetector') }}"

In the above example, the Pixoo would display

Motion-FL1: [on/off]

Conditionally replacing text based on sensor readings

What if you want to change on -> detected and off -> clear?

One way is to use a combination of If/then/else (short form below) and a state comparator (is_state)

content: >-
Motion-FL1: {{ 'Detected' if
is_state('binary_sensor.MotionDetector', ['on']) else
'clear' }}

You might say "well that's pretty nifty, but I also want to dynamically change the color because a e s t h e t i c s.

Well I've got great news for you!

Using templates to dynamically change text color

We can take the exact same concept used for the text, and apply it to color. All we need to do is swap text for color codes.

If Motion Detected, color = red (255,0,0); else color = green (0,255,0)

color: >-
{{ [255,0,0] if is_state('binary_sensor.motionDetector',
['on']) else [0,255,0] }}

Animations through automations

Note

In this example we're using a count helper to act as a countdown. This also uses an automation and not the config.

alias: pixoo64 - auto-ani
description: ""
trigger: []
condition: []
action:
  - service: counter.reset
    metadata: {}
    data: {}
    target:
      entity_id: counter.pixoo_5s_count_down
  - repeat:
      count: 20
      sequence:
        - service: divoom_pixoo.show_message
          target:
            entity_id: sensor.divoom_pixoo_64_current_page
          data:
            page_data:
              page_type: components
              components:
                - type: text
                  position:
                    - 0
                    - 30
                  content: "Auth Check in: {{ states('counter.pixoo_5s_count_down') }}"
                  font: pico_8
                  color: white
                - type: image
                  image_url: https://pub.inflowbogie.dev/lock_closed.png
                  position:
                    - 0
                    - 40
                  resample_mode: box
                  height: 20
                - type: image
                  image_url: https://pub.inflowbogie.dev/key.png
                  position:
                    - "{{ 2 * states('counter.pixoo_5s_count_down') }}"
                    - 50
                  resample_mode: box
                  height: 7
        - service: counter.decrement
          metadata: {}
          data: {}
          target:
            entity_id: counter.pixoo_5s_count_down
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - if:
            - condition: state
              entity_id: counter.pixoo_5s_count_down
              state: "0"
          then:
            - service: counter.reset
              metadata: {}
              data: {}
              target:
                entity_id: counter.pixoo_5s_count_down
mode: single

animated

References

Fonts

Font Image
gicko FONT_GICKO.png
five_pix five_pix.png
pico_8 PICO_8.png
eleven_pix eleven_pix.png
clock CLOCK.png


Color Presets

The colors in this chart can be used as presets to replace the [R,G,B] color coding.



Issues

Sometimes the display crashes, especially with animated images. I have often read on the Internet that this is due to the power supply being too weak or the brightness being too high. I now have the display permanently set to 90% and it no longer crashes.



Discussions

I would be happy if you present your own configuration/usages of the integration or ask questions in the discussions!

https://github.com/gickowtf/pixoo-homeassistant/discussions



Disclaimer

This is not official software from Divoom.

It is a custom integration created by me (gickowtf) and therefore Divoom is not responsible for any damages/problems caused by this integration, nor does Divoom provide any end-user support for the integration.

Use this integration at your own risk.



❤️ Many thanks to

@Mrredstone5230 - Thanks for the conversion to config flow and many many more

pixoo-homeassistant's People

Contributors

gickowtf avatar ireneybean avatar koendierckx avatar mrredstone5230 avatar steamengineer avatar yyolk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pixoo-homeassistant's Issues

Service call seems to not work

I'm not sure if its since the last update with the connection fix, but now when I do a service call HA says succes, but nothing is displayed on the Pixoo. Enabled debug logging and all but I see no errors.

I think it has something to do with the latest Pixoo update.

Frequently goes unavailable

Heyo. I have tried a few things and I ruled out that it is a network/wifi issue. While the pixoo is being ping from home assistant or any other location on my network, it will frequently respond with minimal variance in response time and no dropped packets.

Relevant log files:

  • Trying to add from config flow (this eventually works)
    ERROR (MainThread) [custom_components.divoom_pixoo.config_flow] Error setting up Pixoo: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

  • Trying to reload the integration entry
    ERROR (MainThread) [custom_components.divoom_pixoo] Error setting up Pixoo: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

  • General log spam from integration
    ERROR (MainThread) [custom_components.divoom_pixoo] Error setting up Pixoo: HTTPConnectionPool(host='192.168.1.X', port=80): Max retries exceeded with url: /post (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f9e03b51e20>, 'Connection to 192.168.1.X timed out. (connect timeout=9)'))

  • Log entry from an automation I made to reload the integration if it become unavailable for 5 minutes
    ERROR (MainThread) [custom_components.divoom_pixoo] Error setting up Pixoo: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Add more options

Hello,

it would be nice to have more options like brigthness and so on.

till now i used this:

configuration.yaml:

rest_command:
  # http://doc.divoom-gz.com/web/#/12?page_id=196
  pixoo64_set_brightness:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Channel/SetBrightness", "Brightness":{{ brightness }}}'
    content_type: "application/json; charset=utf-8"
  pixoo64_switch_off:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Channel/OnOffScreen", "OnOff":0}'
    content_type: "application/json; charset=utf-8"
  pixoo64_switch_on:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Channel/OnOffScreen", "OnOff":1}'
    content_type: "application/json; charset=utf-8"
  pixoo64_set_channel:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Channel/SetIndex", "SelectIndex":{{ effect }}}'
    content_type: "application/json; charset=utf-8"
  pixoo64_set_custom_channel_page:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Channel/SetCustomPageIndex", "CustomPageIndex":{{ page }}}'
    content_type: "application/json; charset=utf-8"
  pixoo64_set_text:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Draw/SendHttpText", "TextId":{{ id }}, "x":0, "y":{{ y }}, "dir":0, "font":{{ font }}, "TextWidth":64, "speed":{{ speed }}, "TextString":"{{ text }}", "color":"{{ color }}", "align":2}'
    content_type: "application/json; charset=utf-8"
  pixoo64_reset_gif:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Draw/ResetHttpGifId"}'
    content_type: "application/json; charset=utf-8"
  pixoo64_send_gif:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Draw/SendHttpGif", "PicNum":1, "PicWidth":64, "PicOffset":0, "PicID":0, "PicSpeed":100, "PicData":"{{ gif }}"}'
    content_type: "application/json; charset=utf-8"
  pixoo64_play_buzzer:
    url: !secret pixoo_post_address
    method: POST
    payload: '{"Command":"Device/PlayBuzzer", "ActiveTimeInCycle":500, "OffTimeInCycle":500, "PlayTotalTime":500}'
    content_type: "application/json; charset=utf-8"

and lights.yaml:

#https://community.home-assistant.io/t/divoom-pixoo-64/420660
- platform: template
  lights:
    pixoo64:
      friendly_name: "Wohnzimmer - Pixoo"
      unique_id: pixoo64
      level_template: "{{ ( state_attr('sensor.pixoo64_data', 'Brightness') * 2.55 ) | round(0) | int  }}"
      value_template: "{{ state_attr('sensor.pixoo64_data', 'LightSwitch')|int == 1 }}"
      effect_list_template: "{{['Faces', 'Cloud Channel', 'Visualizer', 'Custom']}}"
      effect_template: "{{ states('sensor.pixoo64_current_channel') }}"
      turn_on:
        service: rest_command.pixoo64_switch_on
      turn_off:
        service: rest_command.pixoo64_switch_off
      set_level:
        service: rest_command.pixoo64_set_brightness
        data:
          brightness: "{{ ( brightness / 2.55 ) | round(0) | int }}"
      set_effect:
        - service: rest_command.pixoo64_set_channel
          data:
            effect: >-
              {% if effect == 'Faces' %}
              0
              {% elif effect == 'Cloud Channel' %}
              1
              {% elif effect == 'Visualizer' %}
              2
              {% else %}
              3
              {% endif %}

but somehow after some days ic ant reach the device and i need to restart it.

i posted some links maybe they can help.

Thanks

Divoo 64 brightness

Hi guys. Please help me.
After i start to play with HA integration, the brightness on my Divoo 64 start to be like 50%.
The Divoo app shows 100%, HA shows 100%, and if I turn the brightness lower, it works. But now when it 100% its not 100% in real life.
When i reboot the display using reconnect usbc cable - it looks 100% when loading, but when loaded it is like half of the brightness again.
Can you help me what to do and how to bring back 100% brighness?
Thank you.

Support for new line \n

First of all thanks so much for building this awesome Integration!
While building a dashboard for it I ran into an issue when trying to display a list of items based on certain filter criteria. Everything works totally fine except for that I want a new line after every entry (ofc only if the entry itself is shown as to always start the list from the top and use as little space as possible. This throws the following error:

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/divoom_pixoo/pixoo64/_pixoo.py:245
Integration: Divoom Pixoo 64 (documentation, issues)
First occurred: 16:42:36 (5 occurrences)
Last logged: 16:43:36

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/config/custom_components/divoom_pixoo/sensor.py", line 108, in _async_update
    await self._async_update_data()
  File "/config/custom_components/divoom_pixoo/sensor.py", line 169, in _async_update_data
    await self.hass.async_add_executor_job(update)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/divoom_pixoo/sensor.py", line 160, in update
    pixoo.draw_text(rendered_text, tuple(text['position']), tuple(text['font_color']), FONT_PICO_8)
  File "/config/custom_components/divoom_pixoo/pixoo64/_pixoo.py", line 245, in draw_text
    matrix += retrieve_glyph(character, font)[-1] + 1
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
TypeError: 'NoneType' object is not subscriptable

Config used:

divoom_pixoo:
  ip_address: 'X'
  scan_interval:
    seconds: 15
  pages:
    - page: 1
      texts:
        - text: >-
            {% if (states.sensor.discord_user_201379156850769920.state) | string != offline | string %}{{ states.sensor.HIDDEN.attributes.user_name }} {% if (states.sensor.HIDDEN.attributes.game) | string != None | string %} {{ states.sensor.HIDDEN.attributes.game[0:6] }}..{% else %}{{ states.sensor.HIDDEN.state }}{% endif %} \n {% endif %}
          position: [1, 1]
          font: FONT_PICO_8
          font_color: [0, 255, 0]

Removing \n from the config removes the error message

Font five_pix doesn't support special character % and °

I tried to display the battery percentage on the Divoom display using the font five_pix. The special character "%" couldn't be used. Instead of the "%" an "?" is displayed, which seems to be used, if a special character is not accepted. The same issue occurs, if you try to display temperatures and wanted to use the "°" character.

If I use the font pico_8, I can display "%", but also not the special character "°".

[Feature Idea] Rearranging the configuration structure

Alright, so I didn't code it yet, but I find the way the configuration is organized to be a little confusing to my liking.

What I'm proposing is a configuration based on components instead of "texts, images, channel, etc"...
I think if every page was just a list of components instead of just one big page only, it would allow some more creativity and power for the users. (That would for example allow people to make the PV page fully in the configuration page using components, and not having to code it in in python). This could also allow you to add some more custom components instead of custom pages entirely. (and I have some ideas for those too!). It could also allow users to control the overlap, if it occurs. This new formatting should also be used in the services for continuity, if implemented.

This is what I'm thinking a new config should look like. Still pages based, but inside the pages is components.

- page: 1
  components:
  - type: text
    position: [17, 18]
    content: '{{ states.sensor.YOUR_SENSOR.state }}'
    color: '{{ "red" if float(states.sensor.YOUR_SENSOR.state) <= 1 else "green"}}'
    font: PICO_8

  - type: image
    position: [1, 16]
    image_path: '{% set num = float(states.input_number.test.state) %} {% if num >= 80 %} /config/custom_components/divoom_pixoo/img/akku80-100.png {% elif num >= 100 %} /config/custom_components/divoom_pixoo/img/akku60-80.png {% else %} /config/custom_components/divoom_pixoo/img/akku40-60.png {% endif %}'

#etc for the PV page, for example.

- page: 2
  components:
  - type: text
    position: [0, 10]
    content: "github/gickowtf"
    font: PICO_8
    color: [255, 0, 0] # or write "red"

  - type: text
    content: "Thx 4 Support"
    position: [0, 30]
    font: PICO_8
    color: [255, 0, 0]  # red

  - type: image
    position: [30, 10]
    image_path: "/config/img/anyPicture.png" #max 64 x 64 Pixel

- page: 3
  components:
  - type: channel
    id: 2
  #Of course, here it's theoretically possible to add more components, although it would override the 'channel' component.

- page : 4
  components:
  - type: clock
    id: 39
  # same story than page 3 here.

Now as you can see, it's not a perfect solution: There is quite a lot of coding still (mostly in the "PV remake") But, I believe that this is a better solution than before, since now people can just share their solutions with each other in plain text instead of relying on this extension to add the page they want.

(PS: I do know that the PV page if already implementable currently, but I think that the general way of organizing the data is a bit nicer/clearer here.)

Let me know what you think!

Crashing when images are used in combination with multiple pages

Hi,
I have noticed this issue when using custom images on a text page. Pixoo will not crash/reboot if there is only one page with combo of images and texts in yaml, however, if I add any additional page, ie. some clock or channel on the 2nd page, it will crash after looping back to the 1st page.
If there's only text on the page, without any image, it will loop normally through pages.
Example:
`ip_address: 'xxx.xxx.xxx.xxx'
scan_interval:
seconds: 15
pages:

  • page: 1
    texts:
    • text: "{{ states.sensor.tado_heating_temperature.state | round(1) }} C"
      position: [20, 7]
      font: FONT_PICO_8
      font_color: [50, 205, 50]
    • text: "{{ states.sensor.tado_heating_helper_outdoor_temperature.state | round(1) }} C"
      position: [20, 25]
      font: FONT_PICO_8
      font_color: [50, 205, 50]
    • text: "{{ states.sensor.tado_heating_humidity.state | round(1) }} %"
      position: [20, 43]
      font: FONT_PICO_8
      font_color: [50, 205, 50]
      images:
    • image: "/config/custom_components/divoom_pixoo/img/inside_temperature.png" #max 64 x 64 Pixel
      position: [1, 1]
    • image: "/config/custom_components/divoom_pixoo/img/outside_temperature.png" #max 64 x 64 Pixel
      position: [1, 18]
    • image: "/config/custom_components/divoom_pixoo/img/inside_humidity.png" #max 64 x 64 Pixel
      position: [1, 35]
  • page: 2
    channel:
    • number: 1`

This will crash, but if I remove or comment out images section, or have only 1st page, it'll work normally.

EDIT: adding a log from HA

`This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/divoom_pixoo/pixoo64/_pixoo.py:386
Integration: Divoom Pixoo 64 (documentation, issues)
First occurred: 23:36:12 (9 occurrences)
Last logged: 23:39:12

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 416, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 244, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.12/http/client.py", line 1327, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.12/http/client.py", line 1373, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.12/http/client.py", line 1322, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.12/http/client.py", line 1081, in _send_output
self.send(msg)
File "/usr/local/lib/python3.12/http/client.py", line 1025, in send
self.connect()
File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f3cc40f66f0>: Failed to establish a new connection: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 799, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.50.225', port=80): Max retries exceeded with url: /post (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3cc40f66f0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/config/custom_components/divoom_pixoo/sensor.py", line 108, in _async_update
await self._async_update_data()
File "/config/custom_components/divoom_pixoo/sensor.py", line 169, in _async_update_data
await self.hass.async_add_executor_job(update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/divoom_pixoo/sensor.py", line 134, in update
pixoo = Pixoo(self._ip_address)
^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/divoom_pixoo/pixoo64/_pixoo.py", line 86, in init
self.__load_counter()
File "/config/custom_components/divoom_pixoo/pixoo64/_pixoo.py", line 386, in __load_counter
response = requests.post(self.__url, '{"Command": "Draw/GetHttpGifId"}')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.50.225', port=80): Max retries exceeded with url: /post (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3cc40f66f0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
`

UPDATE 1: I've found out some kind of a workaround for this - as long as there's some lighter page (text only) put between heavier (ie. clock, channel...) and a custom page (with text and images), it will not crash.

No light entity

Hello. Thanks for the integration. I just updated to the latest version. Removed the entry from config.yaml and added with the config flow.

It now displays the device but the only entity is a "current page" diagnostic sensor. Please let me know if I've done something wrong!

Stops switching pages after a while

I'm not sure what I'm doing wrong, but everyday it just stops changing the pages and I have to restart HA to get it going again. Is there an option somewhere I need to check?

page Refresh

Is there a way to trigger a page refresh without switching to the next page? I currently use your integration to display data from my PV power plant. Since it changes quite frequently, I would like to refresh every 5 seconds, but still switch to the next page after i.e. 15 seconds or so. Right now I just duplicated the page :-)

"Duration" from a variable

I am struggling around with following issue:
I want to define the duration of the pages with a input_number.

I cannot get this work.

duration: "{{ states('input_number.divoom_duration') }}"

With the following code the value of the variable will be displayed:

- type: text
  content: "{{ states('input_number.divoom_duration') }}"
  font: five_pix
  position:
	- 1
	- 1
	

But as soon I enter the duration part the page will not be displayed

What I am doing wrong?

Page no longer reloads

Hey. Sorry, me again.

I've noticed that the page gets stuck quite regularly. There was a fix for that last week (#74) to prevent the integration from crashing when the Pixoo does not repond right away. It is already on main, as far as I can tell.

Will there be a release soon? Or is there a way for me to install the integration from main?

Unable to add repository

adding this repo to HAOS, I get the following error:

https://github.com/gickowtf/pixoo-homeassistant is not a valid add-on repository

Relative noob to this so unsure if this is my fault or an actual issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.