Last active
June 30, 2024 11:05
-
-
Save kmplngj/bc6352d954a722b6ad95c1c165125ed7 to your computer and use it in GitHub Desktop.
Home Assistant Configuration to add a Divoom Pixoo 64 as a light. Feel free to help me optimise this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set pixoo_post_address in your secrets.yaml to your Pixoo64 rest api post address | |
# pixoo_post_address: http://192.168.foo.bar/post | |
# if you host Pixoo-Rest you could set url in the pixoo_rest_imageurl command | |
sensor: | |
- platform: rest | |
name: pixoo64 Data | |
resource: !secret pixoo_post_address | |
method: POST | |
payload: '{ "Command" : "Channel/GetAllConf" }' | |
value_template: "OK" | |
scan_interval: 30 | |
json_attributes: | |
- Brightness | |
- RotationFlag | |
- ClockTime | |
- GalleryTime | |
- SingleGalleyTime | |
- PowerOnChannelId | |
- GalleryShowTimeFlag | |
- CurClockId | |
- Time24Flag | |
- TemperatureMode | |
- GyrateAngle | |
- MirrorFlag | |
- LightSwitch | |
- platform: rest | |
name: pixoo64 Current Channel Integer | |
resource: !secret pixoo_post_address | |
method: POST | |
payload: '{ "Command" : "Channel/GetIndex" }' | |
value_template: "{{ value_json.SelectIndex }}" # channel id 0~3 ;0:Faces;1:Cloud Channdle;2:Visualizer;3:Custom | |
scan_interval: 30 | |
- platform: template | |
sensors: | |
pixoo64_current_channel: | |
friendly_name: "pixoo64 Current Channel" | |
value_template: >- | |
{% if (states.sensor.pixoo64_current_channel_integer.state|int == 0) %} | |
Faces | |
{% elif (states.sensor.pixoo64_current_channel_integer.state|int == 1) %} | |
Cloud Channel | |
{% elif (states.sensor.pixoo64_current_channel_integer.state|int == 2) %} | |
Visualizer | |
{% else %} | |
Custom | |
{% endif %} | |
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: | |
url: !secret pixoo_post_address | |
method: POST | |
payload: '{"Command":"Channel/SetCustomPageIndex", "SelectIndex": {{ custompageindex }}}' | |
content_type: "application/json; charset=utf-8" | |
pixoo64_set_text: | |
url: !secret pixoo_post_address | |
method: POST | |
payload: '{"Command":"Draw/SendHttpText", "TextId":{{ id }}, "x":{{ x }}, "y":{{ y }}, "dir":{{ Direction }}, "font":{{ Font }}, "TextWidth":{{ TextWidth }}, "speed":{{ Speed }}, "TextString":"{{ Text }}", "color":"{{ Color }}", "align":{{ Align }}}' | |
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" | |
pixoo64_rotate_screen: | |
url: !secret pixoo_post_address | |
method: POST | |
payload: '{"Command":"Device/SetScreenRotationAngle", "Mode":{{ mode }}}' | |
content_type: "application/json; charset=utf-8" | |
pixoo_rest_imageurl: | |
url: "http://homeassistant.local:5000/imageurl" | |
payload: "imageurl={{ Imageurl | urlencode }}&x={{ x }}&y={{ y }}&push_immediately=true" | |
content_type: "application/x-www-form-urlencoded" | |
method: POST | |
headers: | |
accept: "application/json" | |
light: | |
- platform: template | |
lights: | |
pixoo64: | |
friendly_name: "Pixoo" | |
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 }}" | |
icon_template: >- | |
mdi:space-invaders | |
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 %} | |
input_button: | |
pixoo64_set_custom_channel_1: | |
name: Pixoo64 Set Custom Channel 1 | |
icon: mdi:lightning-bolt | |
pixoo64_set_custom_channel_2: | |
name: Pixoo64 Set Custom Channel 2 | |
icon: mdi:lightning-bolt | |
pixoo64_set_custom_channel_3: | |
name: Pixoo64 Set Custom Channel 3 | |
icon: mdi:lightning-bolt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment