Open nicoCRX opened 2 years ago
Ah, yes, sorry, I forgot to check that script in. Problem is that ESPHome can't send an array of numbers to home assistant service, so you have to create a script that would accept those numbers as separate attributes. Here's the script:
alias: ESPHome RGB light set
sequence:
- service: light.turn_on
data_template:
entity_id: '{{ light_name }}'
rgb_color:
- '{{ red }}'
- '{{ green }}'
- '{{ blue }}'
mode: single
Ok. I'll try this Thanks
i tried this but it doesn't seem to work. pretty new to all this so im very sorry.
i just added this to a script in home assistant but i dont seem to receive the values (the script should be called set_light_rgb) right?
You could add some logging to the ESPHome script to see if you are getting back values from the C++ code, but other then that, it should work. Just heads up, I'm reasonably sure that there's a memory leak somewhere in C++ code, because NSPanel starts rebooting itself after a period of time when using this code. Unfortunately, I gave up on NSPanel and moved on to using Wink Relay instead, so I'm not planning on trying to fix it.
So after adding logging and figuring out that the vallues werent correct (always 255) i was able to solve that however i still cant pass the values onto home assistant. pretty sure its a service/ script issue. do i understand it correct that i just have to go into my scripts.yaml on home assistant and i can copy paste in your code ? with a script name of set_light_rgb ?
i seemed to have had an issue with using the yaml file. made the automation in gui and than changed the vallues in yaml
now it works like a charm. thank you good sir
Yeah, I haven't tried doing it in yaml files, but instead, just created a script in the UI.
alias: ESPHome RGB light set sequence:
- service: light.turn_on data_template: entity_id: '{{ light_name }}' rgb_color:
- '{{ red }}'
- '{{ green }}'
- '{{ blue }}' mode: single
How did you resolve the issue with wheel?
I am stuck on RGB wheel and can not find the solution.
can't remember exactly what i did, just remember it was something stupid with the ui/yaml it didnt work for me when just using the yaml but somehow doing it yaml and ui worked:
i hope the image helps
can't remember exactly what i did, just remember it was something stupid with the ui/yaml it didnt work for me when just using the yaml but somehow doing it yaml and ui worked:
i hope the image helps
I have already added the script but still nothing here, the wheel not changing the colours. the dimmer and brightness controllers are working somehow but the wheel is not changing colours.
I am designing the panel for my needs but I am still missing the RGB controller to make it perfect for my room.
dimmer/brightness are completely seperate from the color wheel,
ok so what i did when i couldnt figure this out is that i built some log debugging to try and find where the problem was. i logged the vallues or red, green, blue in esphome etc
this is my code for the binary sensor, i added some logging (atleast i think i added it, maybe it was allready there)
#color wheel
- platform: nextion
name: $device_name Color Wheel
page_id: 6
component_id: 13
internal: true
on_press:
then:
- script.stop: my_timer
on_release:
then:
- lambda: |-
id(color_wheel_x).update();
id(color_wheel_y).update();
- delay: 20ms
- lambda: |-
RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state);
id(selected_color_red2) = String(color.r);
id(selected_color_green2) = String(color.g);
id(selected_color_blue2) = String(color.b);
- logger.log:
format: "RGB RED VALUE: %s"
args: [ 'id(selected_color_red2).c_str()']
- logger.log:
format: "RGB GREEN VALUE: %s"
args: [ 'id(selected_color_green2).c_str()']
- logger.log:
format: "RGB BLUE VALUE: %s"
args: [ 'id(selected_color_blue2).c_str()']
- homeassistant.service:
service: script.set_light_rgb
data:
light_name: $target_lights
red: !lambda 'return id(selected_color_red2).c_str();'
green: !lambda 'return id(selected_color_green2).c_str();'
blue: !lambda 'return id(selected_color_blue2).c_str();'
- script.execute: my_timer
you didnt forget to add the colorwheel file to the esphome root directory right?
same script here but not responding.
color wheel
- platform: nextion name: $device_name Color Wheel page_id: 6 component_id: 13 internal: true on_press: then:
- script.stop: my_timer on_release: then:
- lambda: |- id(color_wheel_x).update(); id(color_wheel_y).update();
- delay: 20ms
- lambda: |- RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state); id(selected_color_red2) = String(color.r); id(selected_color_green2) = String(color.g); id(selected_color_blue2) = String(color.b);
- logger.log: format: "RGB RED VALUE: %s" args: [ 'id(selected_color_red2).c_str()']
- logger.log: format: "RGB GREEN VALUE: %s" args: [ 'id(selected_color_green2).c_str()']
- logger.log: format: "RGB BLUE VALUE: %s" args: [ 'id(selected_color_blue2).c_str()']
- homeassistant.service: service: script.set_light_rgb data: light_name: $target_lights red: !lambda 'return id(selected_color_red2).c_str();' green: !lambda 'return id(selected_color_green2).c_str();' blue: !lambda 'return id(selected_color_blue2).c_str();'
- script.execute: my_timer
No it is already there
same script here but not responding.
color wheel
- platform: nextion name: $device_name Color Wheel page_id: 6 component_id: 13 internal: true on_press: then:
- script.stop: my_timer on_release: then:
- lambda: |- id(color_wheel_x).update(); id(color_wheel_y).update();
- delay: 20ms
- lambda: |- RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state); id(selected_color_red2) = String(color.r); id(selected_color_green2) = String(color.g); id(selected_color_blue2) = String(color.b);
- logger.log: format: "RGB RED VALUE: %s" args: [ 'id(selected_color_red2).c_str()']
- logger.log: format: "RGB GREEN VALUE: %s" args: [ 'id(selected_color_green2).c_str()']
- logger.log: format: "RGB BLUE VALUE: %s" args: [ 'id(selected_color_blue2).c_str()']
- homeassistant.service: service: script.set_light_rgb data: light_name: $target_lights red: !lambda 'return id(selected_color_red2).c_str();' green: !lambda 'return id(selected_color_green2).c_str();' blue: !lambda 'return id(selected_color_blue2).c_str();'
- script.execute: my_timer
No it is already there
so the vallues are showing in the logger?
To tell you the truth I am trying to integrate it to the EU version so I am suspecting that I am missing any point that is confusing me because this is the first week I am using ESPHome with Nextion editor. Every code I have used is copy paste in combination with my logic :(
######################################################
substitutions:
# Name the device and it's entities
device_name: nspanel-dev
wifi_ssid: !secret wifi_ssid
wifi_pass: !secret wifi_password
tft_url: !secret tft_upload_url
target_lights: light.room_lamp_rgb
# global varibles.
globals:
- id: selected_color_red
type: String
- id: selected_color_green
type: String
- id: selected_color_blue
type: String
############Binary#############
### RGB CONTROLER ##################
- platform: nextion
name: $device_name Brightness Slider
page_id: 9
component_id: 2
internal: true
on_release:
then:
- lambda: !lambda |-
id(brightness_value).update();
- platform: nextion
name: $device_name Color Wheel
page_id: 9
component_id: 17
internal: true
on_release:
then:
- lambda: |-
id(color_wheel_x).update();
id(color_wheel_y).update();
- delay: 20ms
- lambda: |-
RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state);
id(selected_color_red) = String(color.r);
id(selected_color_green) = String(color.g);
id(selected_color_blue) = String(color.b);
- homeassistant.service:
service: script.yeelight_hsv_mode
data:
light_name: $target_lights
red: !lambda 'return id(selected_color_red).c_str();'
green: !lambda 'return id(selected_color_green).c_str();'
blue: !lambda 'return id(selected_color_blue).c_str();'
- platform: nextion
name: $device_name Color Temp Slider
page_id: 9
component_id: 12
internal: true
######### RGB SENSOR ##################
########################################
- platform: homeassistant
id: current_brightness
entity_id: $target_lights
attribute: brightness
on_value:
then:
- lambda: 'id(disp1).send_command_printf("brightnessVal.val=%i", (int)x);'
- platform: homeassistant
id: current_color_temp
entity_id: $target_lights
attribute: color_temp
on_value:
then:
- lambda: 'id(disp1).send_command_printf("tempSlider.val=%i", (int)x);'
- platform: nextion
id: brightness_value
component_name: brightnessVal
on_value:
then:
- homeassistant.service:
service: light.turn_on
data:
entity_id: $target_lights
brightness: !lambda 'return (int)x;'
- platform: nextion
id: color_temp_value
component_name: tempSlider
on_value:
then:
- homeassistant.service:
service: light.turn_on
data:
entity_id: $target_lights
color_temp: !lambda 'return (int)x;'
- platform: nextion
id: color_wheel_x
component_name: selectedColorX
filters:
- offset: -27
- platform: nextion
id: color_wheel_y
component_name: selectedColorY
filters:
- offset: -91
on_release:
then:
- lambda: !lambda |-
id(color_temp_value).update();
its just a timer to turn off the display
Do I have to create a timer because I not using any timer?
To tell you the truth I am trying to integrate it to the EU version so I am suspecting that I am missing any point that is confusing me because this is the first week I am using ESPHome with Nextion editor. Every code I have used is copy paste in combination with my logic :(
###################################################### substitutions:
Name the device and it's entities
device_name: nspanel-dev wifi_ssid: !secret wifi_ssid wifi_pass: !secret wifi_password tft_url: !secret tft_upload_url target_lights: light.room_lamp_rgb
global varibles.
globals:
- id: selected_color_red type: String
- id: selected_color_green type: String
- id: selected_color_blue type: String
############Binary#############
RGB CONTROLER
- platform: nextion name: $device_name Brightness Slider page_id: 9 component_id: 2 internal: true on_release: then:
- lambda: !lambda |- id(brightness_value).update();
- platform: nextion name: $device_name Color Wheel page_id: 9 component_id: 17 internal: true on_release: then:
- lambda: |- id(color_wheel_x).update(); id(color_wheel_y).update();
- delay: 20ms
- lambda: |- RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state); id(selected_color_red) = String(color.r); id(selected_color_green) = String(color.g); id(selected_color_blue) = String(color.b);
- homeassistant.service: service: script.yeelight_hsv_mode data: light_name: $target_lights red: !lambda 'return id(selected_color_red).c_str();' green: !lambda 'return id(selected_color_green).c_str();' blue: !lambda 'return id(selected_color_blue).c_str();'
- platform: nextion name: $device_name Color Temp Slider page_id: 9 component_id: 12 internal: true
######### RGB SENSOR ################## ########################################
- platform: homeassistant id: current_brightness entity_id: $target_lights attribute: brightness on_value: then:
- lambda: 'id(disp1).send_command_printf("brightnessVal.val=%i", (int)x);'
- platform: homeassistant id: current_color_temp entity_id: $target_lights attribute: color_temp on_value: then:
- lambda: 'id(disp1).send_command_printf("tempSlider.val=%i", (int)x);'
- platform: nextion id: brightness_value component_name: brightnessVal on_value: then:
- homeassistant.service: service: light.turn_on data: entity_id: $target_lights brightness: !lambda 'return (int)x;'
- platform: nextion id: color_temp_value component_name: tempSlider on_value: then:
- homeassistant.service: service: light.turn_on data: entity_id: $target_lights color_temp: !lambda 'return (int)x;'
platform: nextion id: color_wheel_x component_name: selectedColorX filters:
- offset: -27
platform: nextion id: color_wheel_y component_name: selectedColorY filters:
offset: -91 on_release: then:
lambda: !lambda |- id(color_temp_value).update();
you added in the extra line in the editor for the eu version if i remember corretly you have to add something, i dont actuelly use a ns panel so i am not sure (i use a nextion display with esp32)
Yes you are right I added extra page that I exported from yliavolodin HMI and imported to EU version HMI.
what is that on release at the end? it seems very out of place, btw don't worry about not understanding it, neither do i. and i am very aware i am not the right person to help but i will try. i myself started my project by copy pasting and adding code to that. after a while you will be able to make your own things.
Yes you are right I added extra page that I exported from yliavolodin HMI and imported to EU version HMI.
the extra line in the program.s
but please try to start the display and tap arround on the colorwheel you need to figure out if the esphome is even getting color vallues and check the logs for these (make sure they are not all the same)
what is that on release at the end? it seems very out of place, btw don't worry about not understanding it, neither do i. and i am very aware i am not the right person to help but i will try. i myself started my project by copy pasting and adding code to that. after a while you will be able to make your own things.
you mean this part?
offset: -27 platform: nextion id: color_wheel_y component_name: selectedColorY filters:
offset: -91 on_release: then:
I tried also without minus also with minus but still same. Sometimes when I am not sure what I am doind I simply try every option heheheh
what is that on release at the end? it seems very out of place, btw don't worry about not understanding it, neither do i. and i am very aware i am not the right person to help but i will try. i myself started my project by copy pasting and adding code to that. after a while you will be able to make your own things.
you mean this part?
offset: -27 platform: nextion id: color_wheel_y component_name: selectedColorY filters:
offset: -91 on_release: then:
I tried also without minus also with minus but still same. Sometimes when I am not sure what I am doind I simply try every option heheheh
yea what is the on release doing there? its a sensor not a binary sensor, to me that seems wrong. why is it there? where does it come from?
also please format your code correctly on here, i cant tell if spacing is wrong, because yes that matters.
To tell you the truth I am trying to integrate it to the EU version so I am suspecting that I am missing any point that is confusing me because this is the first week I am using ESPHome with Nextion editor. Every code I have used is copy paste in combination with my logic :(
###################################################### substitutions:
Name the device and it's entities
device_name: nspanel-dev wifi_ssid: !secret wifi_ssid wifi_pass: !secret wifi_password tft_url: !secret tft_upload_url target_lights: light.room_lamp_rgb
global varibles.
globals:
- id: selected_color_red type: String
- id: selected_color_green type: String
- id: selected_color_blue type: String
############Binary#############
RGB CONTROLER
- platform: nextion name: $device_name Brightness Slider page_id: 9 component_id: 2 internal: true on_release: then:
- lambda: !lambda |- id(brightness_value).update();
- platform: nextion name: $device_name Color Wheel page_id: 9 component_id: 17 internal: true on_release: then:
- lambda: |- id(color_wheel_x).update(); id(color_wheel_y).update();
- delay: 20ms
- lambda: |- RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state); id(selected_color_red) = String(color.r); id(selected_color_green) = String(color.g); id(selected_color_blue) = String(color.b);
- homeassistant.service: service: script.yeelight_hsv_mode data: light_name: $target_lights red: !lambda 'return id(selected_color_red).c_str();' green: !lambda 'return id(selected_color_green).c_str();' blue: !lambda 'return id(selected_color_blue).c_str();'
- platform: nextion name: $device_name Color Temp Slider page_id: 9 component_id: 12 internal: true
######### RGB SENSOR ################## ########################################
- platform: homeassistant id: current_brightness entity_id: $target_lights attribute: brightness on_value: then:
- lambda: 'id(disp1).send_command_printf("brightnessVal.val=%i", (int)x);'
- platform: homeassistant id: current_color_temp entity_id: $target_lights attribute: color_temp on_value: then:
- lambda: 'id(disp1).send_command_printf("tempSlider.val=%i", (int)x);'
- platform: nextion id: brightness_value component_name: brightnessVal on_value: then:
- homeassistant.service: service: light.turn_on data: entity_id: $target_lights brightness: !lambda 'return (int)x;'
- platform: nextion id: color_temp_value component_name: tempSlider on_value: then:
- homeassistant.service: service: light.turn_on data: entity_id: $target_lights color_temp: !lambda 'return (int)x;'
platform: nextion id: color_wheel_x component_name: selectedColorX filters:
- offset: -27
platform: nextion id: color_wheel_y component_name: selectedColorY filters:
offset: -91 on_release: then:
lambda: !lambda |- id(color_temp_value).update();
i noticed your code has no debugging please look at the code i posted and add that in to see the rgb vallues
What code you are using on our script my_timer?
its just a timer to turn off the display
also just checking but you didnt forget to add the includes right?
esphome:
name: $device_name
includes:
- colorwheel.h
also just checking but you didnt forget to add the includes right?
esphome: name: $device_name includes: - colorwheel.h
yes they are added also
# Example config.yaml
esphome:
name: nspanel
comment: $device_name
includes:
- colorwheel.h
ok, well let me know what the logs say otherwise i cant do much
ok, well let me know what the logs say otherwise I cant do much
I am stuck on timer because I never use any so esphome is not letting me load the file you gave me without adding timer script.
then get rid of the line...
then get rid of the line...
ok doing it now
getting errors :(
here is the log I am getting with my current codes
[02:26:17][D][homeassistant.text_sensor:017]: 'sensor.nspanel_dev_temperature': Got state '25.7' [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF
sooo just litarally copy pasting everything wont work, you have to try and read it and see what every line is doing. this was for a second color wheel (not done yet so yea)
this code should be correct
#color wheel
- platform: nextion
name: $device_name Color Wheel
page_id: 9
component_id: 17
internal: true
on_release:
then:
- lambda: |-
id(color_wheel_x).update();
id(color_wheel_y).update();
- delay: 20ms
- lambda: |-
RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state);
id(selected_color_red) = String(color.r);
id(selected_color_green) = String(color.g);
id(selected_color_blue) = String(color.b);
- logger.log:
format: "RGB RED VALUE: %s"
args: [ 'id(selected_color_red).c_str()']
- logger.log:
format: "RGB GREEN VALUE: %s"
args: [ 'id(selected_color_green).c_str()']
- logger.log:
format: "RGB BLUE VALUE: %s"
args: [ 'id(selected_color_blue).c_str()']
- homeassistant.service:
service: script.set_light_rgb
data:
light_name: $target_lights
red: !lambda 'return id(selected_color_red).c_str();'
green: !lambda 'return id(selected_color_green).c_str();'
blue: !lambda 'return id(selected_color_blue).c_str();'
here is the log I am getting with my current codes
[02:26:17][D][homeassistant.text_sensor:017]: 'sensor.nspanel_dev_temperature': Got state '25.7' [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:26:17][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:26:17][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF
is this with the logging ?
now I am loading the codes you just gave me. The log I pasted few seconds ago is from my old config codes.
[02:31:51][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:52][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:52][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:52][D][main:324]: RGB RED VALUE: 255 [02:31:52][D][main:327]: RGB GREEN VALUE: 255 [02:31:52][D][main:330]: RGB BLUE VALUE: 255 [02:31:52][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:52][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:52][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:52][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:53][D][main:324]: RGB RED VALUE: 255 [02:31:53][D][main:327]: RGB GREEN VALUE: 255 [02:31:53][D][main:330]: RGB BLUE VALUE: 255 [02:31:53][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:53][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:53][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:53][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:53][D][main:324]: RGB RED VALUE: 255 [02:31:53][D][main:327]: RGB GREEN VALUE: 255 [02:31:53][D][main:330]: RGB BLUE VALUE: 255 [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:54][D][main:324]: RGB RED VALUE: 255 [02:31:54][D][main:327]: RGB GREEN VALUE: 255 [02:31:54][D][main:330]: RGB BLUE VALUE: 255 [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:54][D][main:324]: RGB RED VALUE: 255 [02:31:54][D][main:327]: RGB GREEN VALUE: 255 [02:31:54][D][main:330]: RGB BLUE VALUE: 255
[02:31:51][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:52][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:52][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:52][D][main:324]: RGB RED VALUE: 255 [02:31:52][D][main:327]: RGB GREEN VALUE: 255 [02:31:52][D][main:330]: RGB BLUE VALUE: 255 [02:31:52][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:52][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:52][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:52][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:53][D][main:324]: RGB RED VALUE: 255 [02:31:53][D][main:327]: RGB GREEN VALUE: 255 [02:31:53][D][main:330]: RGB BLUE VALUE: 255 [02:31:53][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:53][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:53][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:53][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:53][D][main:324]: RGB RED VALUE: 255 [02:31:53][D][main:327]: RGB GREEN VALUE: 255 [02:31:53][D][main:330]: RGB BLUE VALUE: 255 [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:54][D][main:324]: RGB RED VALUE: 255 [02:31:54][D][main:327]: RGB GREEN VALUE: 255 [02:31:54][D][main:330]: RGB BLUE VALUE: 255 [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=PRESS [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [02:31:54][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [02:31:54][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [02:31:54][D][main:324]: RGB RED VALUE: 255 [02:31:54][D][main:327]: RGB GREEN VALUE: 255 [02:31:54][D][main:330]: RGB BLUE VALUE: 255
mmm ok all 255 vallues meaning its not reading correctly
Anyway thank you so much for your shared time but my colour wheel is still useless.
it sucks because i had the same problem just cant remember what it was
i know i had problems with the offset, but im not really sure
Can this be the problem ? U see there are all 255
no the colorwheel.h doesnt have errors as far as i can see
paste your entire code here (leave out any personal info like wifi and stuff) format it correctly!
i did actuelly make changes to the colorwheel.h ill try to redo it to make it compatible for you and you can try that
`# NSPanel YAML by marcfager. Please check github for credits: https://github.com/marcfager/nspanel-mf
Version 2022-01-19
substitutions:
Name the device and it's entities
device_name: nspanel-dev wifi_ssid: !secret wifi_ssid wifi_pass: !secret wifi_password tft_url: !secret tft_upload_url target_lights: light.room_lamp_rgb
global varibles.
globals:
- id: selected_color_red type: String
- id: selected_color_green type: String
- id: selected_color_blue type: String
Example config.yaml
esphome: name: nspanel comment: $device_name includes: - colorwheel.h
esp32: board: esp32dev
Wifi settings. Add these to your secrets.yaml. fast_connect must be true for a hidden ssid.
wifi: ssid: $wifi_ssid password: $wifi_pass
API. Add api_pwd to your secrets.yaml.
api:
services: # Service to play a rtttl tone - service: play_rtttl variables: song_str: string then: - rtttl.play: rtttl: !lambda 'return song_str;' # Service to update the HMI file - service: upload_tft then: - lambda: 'id(disp1)->upload_tft();' # Service to control the visible page from Home Assistant - service: set_page variables: page: int then: - lambda: id(disp1).send_command_printf("page %i", page);
# Service to show a notification on the screen for 15 s. Tap or wait to close - service: notification variables: header: string message: string then: - lambda: |- id(disp1).set_component_text_printf("Notifications.head", "%s", header.c_str()); id(disp1).set_component_text_printf("Notifications.body", "%s", message.c_str()); id(disp1).send_command_printf("page 6"); - rtttl.play: "twobits:d=4,o=5,b=220:c6,8g,8g,a,g,p,b,c6" - delay: 30s - lambda: |- id(disp1).send_command_printf("page 0"); id(disp1).set_component_text_printf("Notifications.head", " "); id(disp1).set_component_text_printf("Notifications.body", " "); id(disp1).send_command_printf("page 0"); # Service to send a command directly to the display. Useful for testing - service: send_command variables: cmd: string then: - lambda: 'id(disp1).send_command_printf("%s", cmd.c_str());' # Service to show a QR code on the display (ex. for WiFi password) - service: display_qr variables: qrdata: string then: - lambda: |- id(disp1).set_component_text_printf("QR.qr0", "%s", qrdata.c_str()); id(disp1).send_command_printf("page 7"); - delay: 15s - lambda: |- id(disp1).send_command_printf("page 0"); id(disp1).send_command_printf("QR.qr0.txt="); id(disp1).send_command_printf("page 0"); # Service to wake up screen - service: wakeup_screen then: - lambda: |- id(disp1).send_command_printf("page 0");
Time component that fetches time from Home Assistant and updates the display once a minute and when the display is ready at bootup (and time is available).
time:
platform: homeassistant id: homeassistant_time on_time:
seconds: 0 minutes: /1 then:
lambda: |- id(disp1).set_component_text_printf("Screensaver.time", "%02i:%02i", id(homeassistant_time).now().hour, id(homeassistant_time).now().minute); id(disp1).set_component_text_printf("Screensaver.date", "%i-%02i-%02i", id(homeassistant_time).now().year, id(homeassistant_time).now().month, id(homeassistant_time).now().day_of_month);
on_time_sync: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- id(disp1).set_component_text_printf("Screensaver.time", "%02i:%02i", id(homeassistant_time).now().hour, id(homeassistant_time).now().minute); id(disp1).set_component_text_printf("Screensaver.date", "%i-%02i-%02i", id(homeassistant_time).now().year, id(homeassistant_time).now().month, id(homeassistant_time).now().day_of_month);
Logger. Disable the temperature sensor etc. to focus on the HMI development
logger: baud_rate: 0 level: DEBUG logs: sensor: WARN resistance: WARN text_sensor: WARN ntc: WARN
OTA (Over the air updates) password. Add to your secrets.yaml
ota:
Uart for the Nextion display
uart: tx_pin: 16 rx_pin: 17 baud_rate: 115200 id: tf_uart
Functionality for the Nextion display
external_components:
- source: github://pr#2956 components: [nextion] refresh: 1h
A reboot button is always useful
button:
- platform: restart name: $device_name Restart
==============================================================================# ############# BINARY SENSORS / Physical Buttons in NSPanel ##################### #==============================================================================
Binary sensors
binary_sensor:
platform: gpio name: $device_name Left Button pin: number: 14 inverted: true on_click:
- switch.toggle: relay_1
platform: gpio name: $device_name Right Button pin: number: 27 inverted: true on_click:
- switch.toggle: relay_2
==============================================================# ############# BINARY SENSORS / Music page ##################### #==============================================================
Buttons on the Music page
- platform: nextion name: $device_name Music previous page_id: 1 component_id: 1
- platform: nextion name: $device_name Music next page_id: 1 component_id: 3
- platform: nextion name: $device_name Music cast page_id: 1 component_id: 4
- platform: nextion name: $device_name Music volup page_id: 1 component_id: 8
- platform: nextion name: $device_name Playlist cocktail page_id: 1 component_id: 9
- platform: nextion name: $device_name Playlist food page_id: 1 component_id: 10
- platform: nextion name: $device_name Playlist dance page_id: 1 component_id: 11
- platform: nextion name: $device_name Playlist note page_id: 1 component_id: 12
================================================================# ############# BINARY SENSORS / Light buttons ##################### #================================================================
LIGHTS BUTTONS
platform: nextion name: $device_name Light 1 button page_id: 2 component_id: 14 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.k1_l2
platform: nextion name: $device_name Light 2 button page_id: 2 component_id: 5 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.room_lamp_rgb
platform: nextion name: $device_name Light 3 button page_id: 2 component_id: 6 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.spot_kitchen
platform: nextion name: $device_name Light 4 button page_id: 2 component_id: 17 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.test3
platform: nextion name: $device_name Light 5 button page_id: 2 component_id: 18 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.test2
platform: nextion name: $device_name Light 6 button page_id: 2 component_id: 19 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.test1
RGB CONTROLER
- platform: nextion name: $device_name Brightness Slider page_id: 9 component_id: 2 internal: true on_release: then:
- lambda: !lambda |- id(brightness_value).update();
color wheel
- platform: nextion name: $device_name Color Wheel page_id: 9 component_id: 17 internal: true on_release: then:
- lambda: |- id(color_wheel_x).update(); id(color_wheel_y).update();
- delay: 20ms
- lambda: |- RgbColor color = posToColor(id(color_wheel_x).state, id(color_wheel_y).state); id(selected_color_red) = String(color.r); id(selected_color_green) = String(color.g); id(selected_color_blue) = String(color.b);
- logger.log: format: "RGB RED VALUE: %s" args: [ 'id(selected_color_red).c_str()']
- logger.log: format: "RGB GREEN VALUE: %s" args: [ 'id(selected_color_green).c_str()']
- logger.log: format: "RGB BLUE VALUE: %s" args: [ 'id(selected_color_blue).c_str()']
- homeassistant.service: service: script.set_light_rgb data: light_name: $target_lights red: !lambda 'return id(selected_color_red).c_str();' green: !lambda 'return id(selected_color_green).c_str();' blue: !lambda 'return id(selected_color_blue).c_str();'
- platform: nextion name: $device_name Color Temp Slider page_id: 9 component_id: 12 internal: true on_release: then:
- lambda: !lambda |- id(color_temp_value).update();
======================================================# ################## COVER BUTTONS ##################### #======================================================
COVER BUTTONS
platform: nextion name: $device_name Light 10 button page_id: 4 component_id: 13 on_click:
- homeassistant.service: service: cover.open_cover data: entity_id: cover.sonoff_10016e3584
platform: nextion name: $device_name Light 11 button page_id: 4 component_id: 14 on_click:
- homeassistant.service: service: cover.stop_cover data: entity_id: cover.sonoff_10016e3584
platform: nextion name: $device_name Light 12 button page_id: 4 component_id: 15 on_click:
- homeassistant.service: service: cover.close_cover data: entity_id: cover.sonoff_10016e3584
platform: nextion name: $device_name Light 13 button page_id: 4 component_id: 12 on_click:
- homeassistant.service: service: cover.open_cover data: entity_id: cover.sonoff_10015f8ad9
platform: nextion name: $device_name Light 14 button page_id: 4 component_id: 16 on_click:
- homeassistant.service: service: cover.stop_cover data: entity_id: cover.sonoff_10015f8ad9
platform: nextion name: $device_name Light 15 button page_id: 4 component_id: 17 on_click:
- homeassistant.service: service: cover.close_cover data: entity_id: cover.sonoff_10015f8ad9
platform: nextion name: $device_name Light 16 button page_id: 4 component_id: 21 on_click:
- homeassistant.service: service: cover.open_cover data: entity_id: cover.lr_roller_shutter_group
platform: nextion name: $device_name Light 17 button page_id: 4 component_id: 22 on_click:
- homeassistant.service: service: cover.stop_cover data: entity_id: cover.lr_roller_shutter_group
platform: nextion name: $device_name Light 17 button page_id: 4 component_id: 23 on_click:
- homeassistant.service: service: cover.close_cover data: entity_id: cover.lr_roller_shutter_group
SCENES BUTTONS
platform: nextion name: $device_name Scenes 4-th button page_id: 3 component_id: 8 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.test6
platform: nextion name: $device_name Scenes 5-th button page_id: 3 component_id: 9 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.test7
platform: nextion name: $device_name Scenes 6-th button page_id: 3 component_id: 10 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.test8
platform: nextion name: $device_name Light 4 button page_id: 10 component_id: 5 on_click:
- homeassistant.service: service: light.toggle data: entity_id: light.test9
MUSIC BUTTONS
platform: nextion name: $device_name Music 12-th button page_id: 1 component_id: 12 on_click:
- homeassistant.service: service: script.play_pause data: entity_id: media_player.volumio
platform: nextion name: $device_name Music 1-th button page_id: 1 component_id: 1 on_click:
- homeassistant.service: service: script.next_music_track data: entity_id: media_player.volumio
platform: nextion name: $device_name Music 2-th button page_id: 1 component_id: 2 on_click:
- homeassistant.service: service: script.next_music_track_2 data: entity_id: media_player.volumio
platform: nextion name: $device_name Music 7-th button page_id: 1 component_id: 7 on_click:
- homeassistant.service: service: media_player.volume_up data: entity_id: media_player.volumio
platform: nextion name: $device_name Music 6-th button page_id: 1 component_id: 6 on_click:
- homeassistant.service: service: media_player.volume_down data: entity_id: media_player.volumio
FAVORITE RADIOS
platform: nextion name: $device_name Fvorites 7-th button page_id: 8 component_id: 7 on_click:
- homeassistant.service: service: script.1654893908316 data: entity_id: media_player.volumio
platform: nextion name: $device_name Fvorites 6-th button page_id: 8 component_id: 6 on_click:
- homeassistant.service: service: script.90s90s_hits data: entity_id: media_player.volumio
platform: nextion name: $device_name Fvorites 7-th button page_id: 8 component_id: 7 on_click:
- homeassistant.service: service: script.90s90s_love data: entity_id: media_player.volumio
platform: nextion name: $device_name Fvorites 8-th button page_id: 8 component_id: 8 on_click:
- homeassistant.service: service: script.bigfm_berlin data: entity_id: media_player.volumio
platform: nextion name: $device_name Fvorites 9-th button page_id: 8 component_id: 9 on_click:
- homeassistant.service: service: script.1fm_absolute_top_40 data: entity_id: media_player.volumio
platform: nextion name: $device_name Favorites 10-th button page_id: 8 component_id: 10 on_click:
- homeassistant.service: service: script.radio_tt data: entity_id: media_player.volumio
platform: nextion name: $device_name Favorites 5-th button page_id: 8 component_id: 5 on_click:
- homeassistant.service: service: script.1654893908316 data: entity_id: media_player.volumio
platform: nextion name: $device_name Favorites 11-th button page_id: 8 component_id: 11 on_click:
- homeassistant.service: service: script.top_ho_radio data: entity_id: media_player.volumio
platform: nextion name: $device_name Favorites 12-th button page_id: 8 component_id: 12 on_click:
- homeassistant.service: service: script.love_radio data: entity_id: media_player.volumio
Air Condition buttons
platform: nextion name: $device_name Clima 22-th button page_id: 7 component_id: 22 on_click:
- homeassistant.service: service: script.living_room_air_conditioner_toggle_power data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name Clima 23-th button page_id: 7 component_id: 23 on_click:
- homeassistant.service: service: script.hvac_auto data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name Clima 24-th button page_id: 7 component_id: 24 on_click:
- homeassistant.service: service: script.hvac_heat data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name Clima 25-th button page_id: 7 component_id: 25 on_click:
- homeassistant.service: service: script.hvac_cool data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name Clima 26-th button page_id: 7 component_id: 26 on_click:
- homeassistant.service: service: script.1670175694586 data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name Clima 27-th button page_id: 7 component_id: 27 on_click:
- homeassistant.service: service: script.hvac_dry data: entity_id: climate.142936511684866_climate
========================# ####### FAN MODE ######## #========================
platform: nextion name: $device_name FAN SILENT page_id: 7 component_id: 7 on_click:
- homeassistant.service: service: script.silent_fan_living_room_ac data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name FAN LOW page_id: 7 component_id: 8 on_click:
- homeassistant.service: service: script.low_fan_living_room_ac data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name FAN MEDIUM page_id: 7 component_id: 9 on_click:
- homeassistant.service: service: script.medium_fan_living_room_ac data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name FAN HIGH page_id: 7 component_id: 10 on_click:
- homeassistant.service: service: script.high_fan_living_room_ac data: entity_id: climate.142936511684866_climate
platform: nextion name: $device_name FAN AUTO page_id: 7 component_id: 11 on_click:
- homeassistant.service: service: script.auto_fan_living_room_ac data: entity_id: climate.142936511684866_climate
########################
Thermostat UP & Down
########################
- platform: nextion name: "$friendly_name Thermostat - Airco setpoint min" page_id: 7 component_id: 3
- platform: nextion name: "$friendly_name Thermostat - Airco setpoint plus" page_id: 7 component_id: 4 ###########################
output:
Buzzer for playing tones
- platform: ledc id: buzzer_out pin: number: 21
switch:
Physical relay 1
- platform: gpio name: $device_name Relay 1 id: relay_1 pin: number: 22
Physical relay 2
- platform: gpio name: $device_name Relay 2 id: relay_2 pin: number: 19
Turn screen power on/off. Easy way to configure the screen power control, but this should not be used from HA, as all components must be re-initialized afterwards. For lights, names of lights etc. this practically means that the state must change once to happen.
- platform: gpio name: $device_name Screen Power id: screen_power entity_category: config pin: number: 4 inverted: true restore_mode: ALWAYS_ON
Basically a global variable to keep track on whether the Nextion display is ready or not. Delays initial info from HA to the display.
- platform: template name: $device_name Nextion inited id: nextion_init entity_category: config restore_state: false assumed_state: off optimistic: true
Show alarm screen on the display and disable it (except for physical buttons).
platform: template name: $device_name Alarm screen id: alarm_activated restore_state: false assumed_state: off optimistic: true on_turn_on:
- lambda: id(disp1).send_command_printf("page 5"); on_turn_off:
- lambda: id(disp1).send_command_printf("page 0");
Disable Dim-down-function on screen
platform: template name: $device_name Disable dim-down id: disp1_disdim restore_state: true assumed_state: off optimistic: true on_turn_on:
- lambda: id(disp1).send_command_printf("Home.disdim.val=1"); on_turn_off:
- lambda: id(disp1).send_command_printf("Home.disdim.val=0");
Disable Screensaver-function on screen
platform: template name: $device_name Disable screensaver id: disp1_dissleep restore_state: true assumed_state: off optimistic: true on_turn_on:
- lambda: id(disp1).send_command_printf("Home.dissleep.val=1"); on_turn_off:
- lambda: id(disp1).send_command_printf("Home.dissleep.val=0");
Disable Go to Home page-function on screen
platform: template name: $device_name Disable go to home id: disp1_disgth restore_state: true assumed_state: off optimistic: true on_turn_on:
- lambda: id(disp1).send_command_printf("Home.disgth.val=1"); on_turn_off:
- lambda: id(disp1).send_command_printf("Home.disgth.val=0");
Rtttl function for buzzer
rtttl: id: buzzer output: buzzer_out
########################################################################## #============================ SENSORS ===================================# ##########################################################################
sensor:
Internal temperature sensor, adc value
- platform: adc id: ntc_source pin: 38 update_interval: 10s attenuation: 11db
Internal temperature sensor, adc reading converted to resistance (calculation)
- platform: resistance id: resistance_sensor sensor: ntc_source configuration: DOWNSTREAM resistor: 11.2kOhm
Internal temperature sensor, resistance to temperature (calculation)
- platform: ntc id: temperature sensor: resistance_sensor calibration: b_constant: 3950 reference_temperature: 25°C reference_resistance: 10kOhm name: $device_name Temperature
Uptime for the display. Also updates a human readable one (further down)
- platform: uptime name: $device_name Uptime Sensor id: uptime_sensor update_interval: 60s on_raw_value: then:
- text_sensor.template.publish: id: uptime_human state: !lambda |- int seconds = round(id(uptime_sensor).raw_state); int days = seconds / (24 3600); seconds = seconds % (24 3600); int hours = seconds / 3600; seconds = seconds % 3600; int minutes = seconds / 60; seconds = seconds % 60; return ( (days ? to_string(days) + "d " : "") + (hours ? to_string(hours) + "h " : "") + (minutes ? to_string(minutes) + "m " : "") + (to_string(seconds) + "s") ).c_str();
WiFi signals strength sensor
- platform: wifi_signal name: $device_name WiFi Signal Sensor update_interval: 60s
Current page displayed on the HMi
- platform: nextion name: $device_name Current display page id: disp1_current_page variable_name: dp update_interval: 1s
Temperature outside, fetched from HA
- platform: homeassistant id: current_temperature entity_id: weather.home attribute: temperature on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Screensaver.temp", "%.1f", id(current_temperature).state);
Temperature outside feels like, fetched from HA
- platform: homeassistant id: temp_feelslike entity_id: sensor.142936511684866_outdoor_temperature on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Screensaver.tempfl", "%.1f", id(temp_feelslike).state);
Air Conditioner temperature, fetched from HA
- platform: homeassistant id: target_temperature entity_id: climate.142936511684866_climate attribute: temperature on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Clima.lractemp", "%.1f", id(target_temperature).state);
Grab current Airco livingroom setpoint from Home Assistant
- platform: homeassistant id: airco_livingroom_setpoint entity_id: climate.142936511684866_climate attribute: temperature internal: true on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: 'id(disp1).set_component_text_printf("Clima.setp_airco_liv", "%.1f", id(airco_livingroom_setpoint).state);'
######################################## ########## RGB SENSOR ################## ########################################
- platform: homeassistant id: current_brightness entity_id: $target_lights attribute: brightness on_value: then:
- lambda: 'id(disp1).send_command_printf("brightnessVal.val=%i", (int)x);'
- platform: homeassistant id: current_color_temp entity_id: $target_lights attribute: color_temp on_value: then:
- lambda: 'id(disp1).send_command_printf("tempSlider.val=%i", (int)x);'
- platform: nextion id: brightness_value component_name: brightnessVal on_value: then:
- homeassistant.service: service: light.turn_on data: entity_id: $target_lights brightness: !lambda 'return (int)x;'
- platform: nextion id: color_temp_value component_name: tempSlider on_value: then:
- homeassistant.service: service: light.turn_on data: entity_id: $target_lights color_temp: !lambda 'return (int)x;'
platform: nextion id: color_wheel_x component_name: selectedColorX filters:
- offset: 27
platform: nextion id: color_wheel_y component_name: selectedColorY filters:
- offset: 91
#################################################################################################### #==================================== TEXT SENSOR =================================================# #################################################################################################### text_sensor:
IP address of device. Not really needed for HA (as HA already knows it), but for showing on the display during startup. The startup screen will leave on if no instance connects to the API.
- platform: wifi_info ip_address: name: $device_name IP address id: ip_address on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Connecting.ip_addr", "%s", id(ip_address).state.c_str());
Uptime in a human readable form. Updated from the uptime sensor
- platform: template name: $device_name Uptime Human Readable id: uptime_human icon: mdi:clock-start
ESPHome version used to compile the app
- platform: version name: $device_name ESPHome Version
Media player entity (or any text entity) to pull currently playing song name from
- platform: homeassistant id: music_artist entity_id: media_player.volumio attribute: media_artist on_value: then:
- lambda: id(disp1).set_component_text_printf("Music.music_sn", "%s", id(music_artist).state.c_str());
Media player entity (or any text entity) to pull currently playing artist name from
- platform: homeassistant id: music_title entity_id: media_player.volumio attribute: media_title on_value: then:
- lambda: id(disp1).set_component_text_printf("Music.music_an", "%s", id(music_title).state.c_str());
Sun sensor from HA. Used to decide whether a sun or moon weather symbol should be used.
- platform: homeassistant id: sun_sun entity_id: sun.sun
Weather symbol, HA weather entity to pull data from
- platform: homeassistant id: weather_symbol entity_id: weather.home on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol=5; // 5 is a empty box. if (id(weather_symbol).state == "clear-night") { symbol=6; } else if (id(weather_symbol).state == "cloudy") { symbol=7; if (id(sun_sun).state == "below_horizon") { symbol=8; } } else if (id(weather_symbol).state == "fog") { symbol=9; } else if (id(weather_symbol).state == "hail" || id(weather_symbol).state == "snowy-rainy") { symbol=10; } else if (id(weather_symbol).state == "lightning") { symbol=11; } else if (id(weather_symbol).state == "lightning-rainy" || id(weather_symbol).state == "exceptional") { symbol=12; if (id(sun_sun).state == "below_horizon") { symbol=13; } } else if (id(weather_symbol).state == "partlycloudy") { symbol=14; if (id(sun_sun).state == "below_horizon") { symbol=8; } } else if (id(weather_symbol).state == "pouring") { symbol=15; } else if (id(weather_symbol).state == "rainy") { symbol=16; } else if (id(weather_symbol).state == "snowy") { symbol=17; } else if (id(weather_symbol).state == "sunny") { symbol=18; if (id(sun_sun).state == "below_horizon") { symbol = 6; } } else if (id(weather_symbol).state == "windy" || id(weather_symbol).state == "windy-variant") { symbol=19; } id(disp1).send_command_printf("Screensaver.weather_symbol.pic=%i", symbol);
Grab current Airco livingroom fan speed from Home Assistant, to show on the display
- platform: homeassistant id: airco_livingroom_fan_speed entity_id: climate.142936511684866_climate attribute: speed internal: true on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Clima.airliv_fan_sp", "%s", id(airco_livingroom_fan_speed).state.c_str());
#############################
LIGHT ICON AND NAME
#############################
Light setup, 1-st light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: koridori_2 entity_id: light.koridori_k1_l2 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 32; if (id(koridori_2).state == "off") { symbol=31; } id(disp1).send_command_printf("Lights.light1.pic=%i", symbol);
Light setup, 1-st light's name
- platform: homeassistant id: koridori_2_name entity_id: light.koridori_k1_l2 attribute: friendly_name on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Lights.light1t", "%s", id(koridori_2_name).state.c_str());
Light setup, 2-nd light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: stop entity_id: light.room_lamp_rgb on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 49; if (id(stop).state == "off") { symbol=48; } id(disp1).send_command_printf("Lights.light2.pic=%i", symbol);
Light setup, 2-nd light's name
- platform: homeassistant id: stop_name entity_id: light.room_lamp_rgb attribute: friendly_name on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Lights.light2t", "%s", id(stop_name).state.c_str());
Light setup, 3-rd light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: stop1 entity_id: light.spot_dritat_e_kuzhines on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 33; if (id(stop1).state == "off") { symbol=34; } id(disp1).send_command_printf("Lights.light3.pic=%i", symbol);
Light setup, 3-rd light's name
- platform: homeassistant id: stop1_name entity_id: light.spot_dritat_e_kuzhines attribute: friendly_name on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Lights.light3t", "%s", id(stop1_name).state.c_str());
Light setup, 4-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: tvpentik entity_id: light.room_lamp_rgb on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 29; if (id(tvpentik).state == "off") { symbol=28; } id(disp1).send_command_printf("Lights.light4.pic=%i", symbol);
Light setup, 5-fth light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: kontorsfonster entity_id: light.koridori_k1_l2 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 29; if (id(kontorsfonster).state == "off") { symbol=28; } id(disp1).send_command_printf("Lights.light5.pic=%i", symbol);
Light setup, 5-fth light's name
- platform: homeassistant id: kontorsfonster_name entity_id: light.koridori_k1_l2 attribute: friendly_name on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Lights.light5t", "%s", id(kontorsfonster_name).state.c_str());
Light setup, 6-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: kontorspentik entity_id: light.koridori_k1_l2 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 29; if (id(kontorspentik).state == "off") { symbol=28; } id(disp1).send_command_printf("Lights.light6.pic=%i", symbol);
Light setup, 6-th light's name
- platform: homeassistant id: kontorspentik_name entity_id: light.koridori_k1_l2 attribute: friendly_name on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Lights.light6t", "%s", id(kontorspentik_name).state.c_str());
################################## ########## COVERS PAGE ########### ##################################
Light setup, 10-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverup entity_id: cover.sonoff_10016e3584 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 23; if (id(coverup).state == "off") { symbol=22; } id(disp1).send_command_printf("Covers.light10.pic=%i", symbol);
Light setup, 11-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverstop entity_id: cover.sonoff_10016e3584 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 27; if (id(coverstop).state == "off") { symbol=26; } id(disp1).send_command_printf("Covers.light11.pic=%i", symbol);
Light setup, 12-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverdown entity_id: cover.sonoff_10016e3584 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 25; if (id(coverdown).state == "off") { symbol=24; } id(disp1).send_command_printf("Covers.light12.pic=%i", symbol);
Light setup, 13-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverupR entity_id: cover.sonoff_10015f8ad9 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 23; if (id(coverup).state == "off") { symbol=22; } id(disp1).send_command_printf("Covers.light13.pic=%i", symbol);
Light setup, 14-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverstopR entity_id: cover.sonoff_10015f8ad9 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 27; if (id(coverstop).state == "off") { symbol=26; } id(disp1).send_command_printf("Covers.light14.pic=%i", symbol);
Light setup, 15-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverdownR entity_id: cover.sonoff_10015f8ad9 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 25; if (id(coverdown).state == "off") { symbol=24; } id(disp1).send_command_printf("Covers.light15.pic=%i", symbol);
Light setup, 16-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverupgroup entity_id: cover.olti_s_roller_shutter_group on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 23; if (id(coverup).state == "off") { symbol=22; } id(disp1).send_command_printf("Covers.light16.pic=%i", symbol);
Light setup, 17-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coverstopgroup entity_id: cover.olti_s_roller_shutter_group on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 27; if (id(coverstop).state == "off") { symbol=26; } id(disp1).send_command_printf("Covers.light17.pic=%i", symbol);
Light setup, 18-th light. If you want to leave a light out, just comment out the section for the light and name.
- platform: homeassistant id: coversdowngroup entity_id: cover.olti_s_roller_shutter_group on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 25; if (id(coverdown).state == "off") { symbol=24; } id(disp1).send_command_printf("Covers.light18.pic=%i", symbol);
######################################## ################ SCENES ################ ########################################
Scene setup, 4-th button.
- platform: homeassistant id: sceneclosed entity_id: light.koridori_k1_l2 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 55; if (id(sceneclosed).state == "off") { symbol=55; } id(disp1).send_command_printf("Scenes.scene4.pic=%i", symbol);
Scene setup, 5-th button.
- platform: homeassistant id: scenehalf entity_id: light.koridori_k1_l2 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 53; if (id(scenehalf).state == "off") { symbol=53; } id(disp1).send_command_printf("Scenes.scene5.pic=%i", symbol);
Scene setup, 6-th button.
- platform: homeassistant id: sceneopen entity_id: light.koridori_k1_l2 on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 54; if (id(sceneopen).state == "off") { symbol=54; } id(disp1).send_command_printf("Scenes.scene6.pic=%i", symbol);
########################## ######### CLIMA ########## ##########################
Clima Power button.
- platform: homeassistant id: poweronoff entity_id: climate.142936511684866_climate on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 68; if (id(poweronoff).state == "off") { symbol=67; } id(disp1).send_command_printf("Clima.poweronoff.pic=%i", symbol);
Clima Auto mode button.
- platform: homeassistant id: automode entity_id: climate.set_hvac_mode on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 59; if (id(automode).state == "off") { symbol=60; } id(disp1).send_command_printf("Clima.automode.pic=%i", symbol);
Clima heat button.
- platform: homeassistant id: heat entity_id: climate.set_hvac_mode on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 57; if (id(heat).state == "off") { symbol=58; } id(disp1).send_command_printf("Clima.heat.pic=%i", symbol);
Clima Cool button.
- platform: homeassistant id: cool entity_id: climate.set_hvac_mode on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 62; if (id(cool).state == "off") { symbol=61; } id(disp1).send_command_printf("Clima.cool.pic=%i", symbol);
Clima Fan button.
- platform: homeassistant id: fan entity_id: climate.set_hvac_mode on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 64; if (id(fan).state == "off") { symbol=63; } id(disp1).send_command_printf("Clima.fan.pic=%i", symbol);
Clima Dry button.
- platform: homeassistant id: dry entity_id: climate.set_hvac_mode on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: |- int symbol = 66; if (id(dry).state == "off") { symbol=65; } id(disp1).send_command_printf("Clima.dry.pic=%i", symbol);
Screensaver, text line 2 (lower right part of screen)
- platform: homeassistant id: screensaver_text2 entity_id: sensor.nspanel_dev_temperature on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Screensaver.text2", "%s", id(screensaver_text2).state.c_str());
Clima page, text line 1 (lower right part of screen)
- platform: homeassistant id: clima_text1 entity_id: climate.142936511684866_climate on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Clima.text1", "%s", id(clima_text1).state.c_str());
Clima page, text line 2 (lower right part of screen)
- platform: homeassistant id: clima_text2 entity_id: sensor.nspanel_dev_temperature on_value: then:
- wait_until: switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("Clima.text2", "%s", id(clima_text2).state.c_str());
number:
Screen brightness
- platform: template name: $device_name Brightness id: brightness entity_category: config unit_of_measurement: '%' min_value: 0 max_value: 100 step: 1 initial_value: 30 set_action: then:
- lambda: 'id(disp1).set_backlight_brightness(x/100);'
- lambda: 'id(disp1).send_command_printf("Home.brightness.val=%i", int(x));'
Screen brightness dimmed down
- platform: template name: $device_name Brightness dimdown id: brightness_dim entity_category: config unit_of_measurement: '%' min_value: 20 max_value: 100 step: 1 initial_value: 1 set_action: then:
- lambda: 'id(disp1).send_command_printf("Home.brightdd.val=%i", int(x));'
Configure the screen itself
display:
- platform: nextion id: disp1 uart_id: tf_uart tft_url: http://192.168.1.176:8123/local/hmi.tft
A little fun...
on_setup: then:
Enable 1 light page (up to 4 available)
- lambda: id(disp1).send_command_printf("Lights.pages.val=1");
- number.set: id: brightness value: 30
- lambda: id(disp1).send_command_printf("page 4");
- wait_until: api.connected
- switch.template.publish: id: nextion_init state: on
- if: condition:
- switch.is_on: alarm_activated then:
- lambda: id(disp1).send_command_printf("page 6"); else:
- delay: 5s
- lambda: id(disp1).send_command_printf("page 0");
`
this format is unreadible please use the "add code option" (select code than press it)
this is the colorwheel.h that i use it has a small change in it im just not sure that it is the issue but i guess its worth a shot (if this doesnt work just delete it)
include <cmath>
typedef struct {
int r;
int g;
int b;
} RgbColor;
typedef struct {
double hue;
double saturation;
double value;
} HsvColor;
double rad2deg(float rad) {
return fmod((360 + 180 * rad / 3.14159265359), 360.0);
}
RgbColor hsv2rgb(HsvColor color) {
double hue = color.hue / 60;
float chroma = (color.value * color.saturation);
float x = chroma * (1 - std::abs(fmod(hue, 2.0) - 1));
float valueChroma = color.value * 255;
float valueX = (x + color.value - chroma) * 255;
float valueZero = (color.value - chroma) * 255;
RgbColor rgb;
if (hue <= 1) {
rgb.r = round(valueChroma);
rgb.g = round(valueX);
rgb.b = round(valueZero);
} else if (hue <= 2) {
rgb.r = round(valueX);
rgb.g = round(valueChroma);
rgb.b = round(valueZero);
} else if (hue <= 3) {
rgb.r = round(valueZero);
rgb.g = round(valueChroma);
rgb.b = round(valueX);
} else if (hue <= 4) {
rgb.r = round(valueZero);
rgb.g = round(valueX);
rgb.b = round(valueChroma);
} else if (hue <= 5) {
rgb.r = round(valueX);
rgb.g = round(valueZero);
rgb.b = round(valueChroma);
} else {
rgb.r = round(valueChroma);
rgb.g = round(valueZero);
rgb.b = round(valueX);
}
return rgb;
}
RgbColor rectToRGB(float x, float y) {
double r = sqrt(x*x + y*y);
float sat = 0;
if (r > 1) {
sat = 255;
} else {
sat = r;
}
HsvColor hsv = {rad2deg(atan2(y, x)), sat, 1};
RgbColor rgb = hsv2rgb(hsv);
return rgb;
}
RgbColor posToColor(float x, float y) {
float r = 213.0f / 2.0f;
float posX = round((x - r) / r * 100) / 100;
float posY = round((r - y) / r * 100) / 100;
RgbColor rgb = rectToRGB(posX, posY);
return rgb;
}
Here is the log using new colorwheel
[03:06:10][D][main:324]: RGB RED VALUE: 86
[03:06:10][D][main:327]: RGB GREEN VALUE: 255
[03:06:10][D][main:330]: RGB BLUE VALUE: 240
[03:06:11][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0
[03:06:12][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0
[03:06:12][D][nextion:439]: Got touch page=9 component=17 type=PRESS
[03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON
[03:06:12][D][nextion:439]: Got touch page=9 component=17 type=RELEASE
[03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF
[03:06:12][D][main:324]: RGB RED VALUE: 86
[03:06:12][D][main:327]: RGB GREEN VALUE: 255
[03:06:12][D][main:330]: RGB BLUE VALUE: 240
[03:06:14][D][nextion:439]: Got touch page=9 component=17 type=PRESS
[03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON
[03:06:14][D][nextion:439]: Got touch page=9 component=17 type=RELEASE
[03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF
[03:06:14][D][main:324]: RGB RED VALUE: 255
[03:06:14][D][main:327]: RGB GREEN VALUE: 255
[03:06:14][D][main:330]: RGB BLUE VALUE: 255`
[03:06:10][D][main:324]: RGB RED VALUE: 86
[03:06:10][D][main:327]: RGB GREEN VALUE: 255
[03:06:10][D][main:330]: RGB BLUE VALUE: 240
[03:06:11][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0
[03:06:12][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0
[03:06:12][D][nextion:439]: Got touch page=9 component=17 type=PRESS
[03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON
[03:06:12][D][nextion:439]: Got touch page=9 component=17 type=RELEASE
[03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF
[03:06:12][D][main:324]: RGB RED VALUE: 86
[03:06:12][D][main:327]: RGB GREEN VALUE: 255
[03:06:12][D][main:330]: RGB BLUE VALUE: 240
[03:06:14][D][nextion:439]: Got touch page=9 component=17 type=PRESS
[03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON
[03:06:14][D][nextion:439]: Got touch page=9 component=17 type=RELEASE
[03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF
[03:06:14][D][main:324]: RGB RED VALUE: 255
[03:06:14][D][main:327]: RGB GREEN VALUE: 255
[03:06:14][D][main:330]: RGB BLUE VALUE: 255
also fix the offsets to be negative
oh ok so now we are getting some vallues why is green 255 tho
Here is the log using new colorwheel
[03:06:10][D][main:324]: RGB RED VALUE: 86 [03:06:10][D][main:327]: RGB GREEN VALUE: 255 [03:06:10][D][main:330]: RGB BLUE VALUE: 240 [03:06:11][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0 [03:06:12][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0 [03:06:12][D][nextion:439]: Got touch page=9 component=17 type=PRESS [03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [03:06:12][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [03:06:12][D][main:324]: RGB RED VALUE: 86 [03:06:12][D][main:327]: RGB GREEN VALUE: 255 [03:06:12][D][main:330]: RGB BLUE VALUE: 240 [03:06:14][D][nextion:439]: Got touch page=9 component=17 type=PRESS [03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [03:06:14][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [03:06:14][D][main:324]: RGB RED VALUE: 255 [03:06:14][D][main:327]: RGB GREEN VALUE: 255 [03:06:14][D][main:330]: RGB BLUE VALUE: 255
[03:06:10][D][main:324]: RGB RED VALUE: 86 [03:06:10][D][main:327]: RGB GREEN VALUE: 255 [03:06:10][D][main:330]: RGB BLUE VALUE: 240 [03:06:11][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0 [03:06:12][E][nextion:527]: ERROR: Received numeric return but next in queue "set_component_text" is not a valid sensor type 0 [03:06:12][D][nextion:439]: Got touch page=9 component=17 type=PRESS [03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [03:06:12][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [03:06:12][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [03:06:12][D][main:324]: RGB RED VALUE: 86 [03:06:12][D][main:327]: RGB GREEN VALUE: 255 [03:06:12][D][main:330]: RGB BLUE VALUE: 240 [03:06:14][D][nextion:439]: Got touch page=9 component=17 type=PRESS [03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state ON [03:06:14][D][nextion:439]: Got touch page=9 component=17 type=RELEASE [03:06:14][D][binary_sensor:036]: 'nspanel-dev Color Wheel': Sending state OFF [03:06:14][D][main:324]: RGB RED VALUE: 255 [03:06:14][D][main:327]: RGB GREEN VALUE: 255 [03:06:14][D][main:330]: RGB BLUE VALUE: 255
press around on every side of the screen what are the vallues?
Hello, I ve use your template to create my own interface for my NSpanel. Thank you for sharing your project. I just have one problem : I don't understand this part:
You are calling a service script ? I have to create a script in my home assistant but with what elements ?
thx