larryk
(Larry)
February 15, 2023, 12:14am
1
I have 2 partitions for a LED WS8212 strip which works just fine as long as you like white LED’s.
I would like to make one partition red and the other green. How do I go about this?
light:
- platform: neopixelbus
type: GRB
pin: GPIO3
num_leds: 32
variant: WS2812
method: ESP8266_DMA
name: LED Light
id: light_1
- platform: partition
name: "Partition Light 1"
id: l1
segments:
# Use first 10 LEDs from the light with ID light_1
- id: light_1
from: 0
to: 3
- platform: partition
name: "Partition Light 2"
id: l2
segments:
# Use LEDs 11-20 from the light with ID light_1
- id: light_1
from: 5
to: 8
Do the lights in HA not show up with a colour wheel?
Also, please check the documentation which recommends to add internal: true
to the original light, to avoid interference with the partitions.
larryk
(Larry)
February 15, 2023, 5:40pm
3
I can get color using other methods:
light:
- platform: neopixelbus
type: GRB
pin: GPIO3
num_leds: 32
variant: WS2812
method: ESP8266_DMA
name: "NeoPixel Light"
id: light_1
on_turn_on:
- light.addressable_set:
id: light_1
range_from: 0
range_to: 32
red: 100%
green: 0%
blue: 100%
But not with partitions.
And, pretty sure that internal: true is only used with effects: which I have not been able to get to work.
You set the neopixelbus component to internal so that this does not show up as a light on its own in HA. Has nothing to do with effects.
larryk
(Larry)
February 15, 2023, 9:36pm
5
That makes sense. Thank you!
Zagor4
(Zagor4)
July 16, 2024, 3:52pm
6
Good Evening, i try to write in this old discussion, because i’ve the same problem.
I can see, in home assistant the colour wheel if i click on the Led Stripe Entity, if i click on the partitions entities, i can only switch on and switch off.
I tried to put “internal” the entity linked to the entire led stripe, but nothing has changed.
Have you solved your problem?
Thanks in advance.
If you have a question about something not working and you dont post your config for people to help you, how exactly can anyone help you? Do you just want everyone to make guesses about what the problem is? Maybe someone tricked you and said we’re all mind readers but, it isnt true! We cant read minds or see your config in your computer so, if you dont post it then no one can help you.
Zagor4
(Zagor4)
July 17, 2024, 7:18am
8
Thanks a lot for your answer!
Following you can find the code that i’m using on a Sonoff TX Ultimate with 32 Led Frame.
At the moment, in home assistant, I can change colour only for the “Neo Pixel Light” (colour Wheel).
I would like change colour also for partitions: for example “nightlight”.
Now if i click on the partition entity in HA i can only switch on / off the LED Partition.
If i want to change colour i have to change the “nightlight_color” parameter in EspHome code.
Thanks a lot in advance
substitutions:
name: "interruttore-sala-tx"
friendly_name: "interruttore-sala-tx"
relay_count: "3"
toggle_relay_1_on_touch: "true"
toggle_relay_2_on_touch: "true"
toggle_relay_3_on_touch: "true"
vibra_time: 150ms
button_on_time: 500ms
button_brightness: "0.7"
button_color: "{0,0,100}"
nightlight_brightness: "0.2"
nightlight_color: "{80,70,0}"
touch_brightness: "1"
touch_color: "{0,100,100}"
touch_effect: "Scan"
long_press_brightness: "1"
long_press_color: "{100,0,0}"
long_press_effect: ""
multi_touch_brightness: "1"
multi_touch_color: "{0,0,0}"
multi_touch_effect: "Rainbow"
swipe_left_brightness: "1"
swipe_left_color: "{0,100,0}"
swipe_left_effect: ""
swipe_right_brightness: "1"
swipe_right_color: "{100,0,70}"
swipe_right_effect: ""
relay_1_pin: GPIO18
relay_2_pin: GPIO17
relay_3_pin: GPIO27
relay_4_pin: GPIO23
vibra_motor_pin: GPIO21
pa_power_pin: GPIO26
led_pin: GPIO13
status_led_pin: GPIO33
uart_tx_pin: GPIO19
uart_rx_pin: GPIO22
audio_lrclk_pin: GPIO4
audio_bclk_pin: GPIO2
audio_sdata_pin: GPIO15
touchpanel_power_pin: GPIO5
esphome:
name: ${name}
friendly_name: ${friendly_name}
project:
name: smarthomeyourself.tx_ultimate
version: "1.0"
on_boot:
priority: -100
then:
- binary_sensor.template.publish:
id: touchfield_1
state: OFF
- binary_sensor.template.publish:
id: touchfield_2
state: OFF
- binary_sensor.template.publish:
id: touchfield_3
state: OFF
- binary_sensor.template.publish:
id: multi_touch
state: OFF
- binary_sensor.template.publish:
id: swipe_left
state: OFF
- binary_sensor.template.publish:
id: swipe_right
state: OFF
- binary_sensor.template.publish:
id: long_press
state: OFF
- script.execute: refresh_led_default
esp32:
board: esp32dev
framework:
type: arduino
logger:
# hardware_uart: UART2
level: DEBUG
logs:
binary_sensor: INFO
light: INFO
script: INFO
switch: INFO
tx_ultimate_touch: INFO
uart_debug: INFO
api:
ota:
- platform: esphome
password: XXXXXXXXXXX
wifi:
ssid: XXXXXXXXX
password: XXXXXXXXXXXX
manual_ip:
# Set this to the IP of the ESP
static_ip: XXXXXXXX
# Set this to the IP address of the router. Often ends with .1
gateway: XXXXXXXXXX
# The subnet of the network. 255.255.255.0 works for most home networks.
subnet: XXXXXXXXXX
ap:
ssid: ${friendly_name} AP
password: XXXXXXXXXXX
improv_serial:
captive_portal:
external_components:
# - source: /config/esphome/my_components
# components: [tx_ultimate_touch]
- source:
type: git
url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome
ref: main
components: [tx_ultimate_touch]
globals:
- id: nightlight_color
type: int [3]
restore_value: no
initial_value: ${nightlight_color}
- id: button_color
type: int [3]
restore_value: no
initial_value: ${button_color}
- id: long_press_color
type: int [3]
restore_value: no
initial_value: ${long_press_color}
- id: multi_touch_color
type: int [3]
restore_value: no
initial_value: ${multi_touch_color}
- id: swipe_left_color
type: int [3]
restore_value: no
initial_value: ${swipe_left_color}
- id: swipe_right_color
type: int [3]
restore_value: no
initial_value: ${swipe_right_color}
- id: touch_color
type: int [3]
restore_value: no
initial_value: ${touch_color}
binary_sensor:
- platform: template
name: "${friendly_name} Touchfield 1"
id: touchfield_1
on_press:
- if:
condition:
lambda: "return ${toggle_relay_1_on_touch};"
then:
- switch.toggle: relay_1
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: touchfield_1
state: OFF
- script.execute: refresh_led_default
- platform: template
name: "${friendly_name} Touchfield 2"
id: touchfield_2
on_press:
- if:
condition:
lambda: "return ${toggle_relay_2_on_touch};"
then:
- switch.toggle: relay_2
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: touchfield_2
state: OFF
- script.execute: refresh_led_default
- platform: template
name: "${friendly_name} Touchfield 3"
id: touchfield_3
on_press:
- if:
condition:
lambda: "return ${toggle_relay_3_on_touch};"
then:
- switch.toggle: relay_3
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: touchfield_3
state: OFF
- script.execute: refresh_led_default
- platform: template
name: "${friendly_name} Swipe left"
id: swipe_left
on_press:
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: swipe_left
state: OFF
- script.execute: refresh_led_default
- platform: template
name: "${friendly_name} Swipe_right"
id: swipe_right
on_press:
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: swipe_right
state: OFF
- script.execute: refresh_led_default
- platform: template
name: "${friendly_name} Multi Touch"
id: multi_touch
on_press:
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: multi_touch
state: OFF
- script.execute: refresh_led_default
- platform: template
name: "${friendly_name} Long Press"
id: long_press
on_press:
- delay: ${button_on_time}
- binary_sensor.template.publish:
id: long_press
state: OFF
- script.execute: refresh_led_default
switch:
- platform: gpio
id: relay_1
name: "${friendly_name} L1"
pin: ${relay_1_pin}
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- script.execute: refresh_led_default
on_turn_off:
then:
- script.execute: refresh_led_default
- platform: gpio
id: relay_2
name: "${friendly_name} L2"
pin: ${relay_2_pin}
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- script.execute: refresh_led_default
on_turn_off:
then:
- script.execute: refresh_led_default
# - platform: gpio
# id: relay_3
# name: "${friendly_name} L3"
# pin: ${relay_3_pin}
# restore_mode: RESTORE_DEFAULT_OFF
# on_turn_on:
# then:
# - script.execute: refresh_led_default
# on_turn_off:
# then:
# - script.execute: refresh_led_default
- platform: template
id: relay_3 # Corridoio scollegato da Relay
name: "${friendly_name} L3"
internal: false
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- script.execute: refresh_led_default
on_turn_off:
then:
- script.execute: refresh_led_default
- platform: gpio
id: vibra
pin: ${vibra_motor_pin}
name: "${friendly_name} Vibration"
restore_mode: ALWAYS_OFF
on_turn_on:
- delay: ${vibra_time}
- switch.turn_off: vibra
- platform: gpio
id: pa_power
pin: ${pa_power_pin}
name: "PA Power"
internal: true
restore_mode: ALWAYS_ON
- platform: gpio
name: "touch panel power"
pin:
number: ${touchpanel_power_pin}
inverted: true
id: touch_power
internal: true
restore_mode: RESTORE_DEFAULT_ON
# - platform: template
# name: "${friendly_name} Nightlight"
# id: nightlight
# internal: true
# optimistic: true
# restore_mode: RESTORE_DEFAULT_OFF
# on_turn_on:
# then:
# - script.execute: refresh_led_default
# on_turn_off:
# then:
# - script.execute: refresh_led_default
- platform: template
name: "${friendly_name} Nightlight"
id: nightlight_active
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
then:
- script.execute: refresh_led_default
on_turn_off:
then:
- script.execute: refresh_led_default
- platform: restart
name: "${friendly_name} Restart"
light:
- platform: neopixelbus
type: GRB
variant: WS2812
pin: ${led_pin}
num_leds: 32
name: "${friendly_name} NeoPixel Light"
id: leds
default_transition_length: 0s
effects:
- addressable_rainbow:
name: "Rainbow"
speed: 30
width: 8
- pulse:
name: "Pulse"
transition_length: 1.4s
update_interval: 1s
on_turn_off:
then:
- script.execute: refresh_led_default
- platform: partition
name: "LEDs Button right"
id: leds_button_right
internal: true
segments:
- id: leds
from: 6
to: 7
- id: leds
from: 16
to: 17
- platform: partition
name: "LEDs Button middle"
id: leds_button_middle
internal: true
segments:
- id: leds
from: 3
to: 4
- id: leds
from: 19
to: 20
- platform: partition
name: "LEDs Button left"
id: leds_button_left
internal: true
segments:
- id: leds
from: 0
to: 1
- id: leds
from: 22
to: 23
- platform: partition
name: "LEDs Top"
id: leds_top
internal: true
segments:
- id: leds # perimetro allargato OK - eliminare eventualmente
from: 25
to: 30
- id: leds
from: 31
to: 31
- id: leds
from: 2
to: 2
- id: leds
from: 5
to: 5
- id: leds
from: 8
to: 8
- id: leds # perimetro allargato OK - eliminare eventualmente
from: 9
to: 14
- id: leds #prova effetti parte sotto eliminare eventualmente
from: 15
to: 15
- id: leds #prova effetti parte sotto eliminare eventualmente
from: 18
to: 18
- id: leds #prova effetti parte sotto eliminare eventualmente
from: 21
to: 21
- id: leds #prova effetti parte sotto eliminare eventualmente
from: 24
to: 24
effects:
- addressable_scan:
name: "Scan"
- addressable_rainbow:
name: "Rainbow"
speed: 10
width: 20
media_player:
- platform: i2s_audio
id: media_out
name: ${friendly_name} Player
dac_type: external
i2s_dout_pin: ${audio_sdata_pin}
i2s_audio_id: audio_i2s
i2s_comm_fmt: lsb
mode: mono
i2s_audio:
id: audio_i2s
i2s_lrclk_pin: ${audio_lrclk_pin}
i2s_bclk_pin: ${audio_bclk_pin}
uart:
tx_pin: ${uart_tx_pin}
rx_pin: ${uart_rx_pin}
id: my_uart
baud_rate: 115200
data_bits: 8
stop_bits: 1
parity: NONE
debug:
direction: RX
dummy_receiver: false
after:
timeout: 2s
bytes: 2048
sequence:
- lambda: UARTDebug::log_hex(direction, bytes, ' ');
tx_ultimate_touch:
id: tx_touch
uart: my_uart
on_press:
- script.execute: led_on_touch
- lambda: >
ESP_LOGD("tx_ultimate_touch.on_press", "Touch Position: %d / State: %d", touch.x, touch.state);
on_release:
- script.execute:
id: handle_release
pos: !lambda "return touch.x;"
- switch.turn_on: vibra
- lambda: >
ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state);
on_swipe_left:
- script.execute: led_on_swipe_left
- switch.turn_on: vibra
- binary_sensor.template.publish:
id: swipe_left
state: ON
- lambda: >
ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state);
on_swipe_right:
- script.execute: led_on_swipe_right
- switch.turn_on: vibra
- binary_sensor.template.publish:
id: swipe_right
state: ON
- lambda: >
ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state);
on_full_touch_release:
- script.execute: led_on_full_touch
- switch.turn_on: vibra
- binary_sensor.template.publish:
id: multi_touch
state: ON
- lambda: >
ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state);
on_long_touch_release:
- script.execute: led_on_long_touch
- switch.turn_on: vibra
- binary_sensor.template.publish:
id: long_press
state: ON
- lambda: >
ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state);
script:
- id: refresh_led_default # SCRIPT PRINCIPALE PER LA GESTIONE DEI LED SU AZIONI.
mode: restart
then:
- light.turn_off: leds_top # VERIFICARE QUESTA CONDIZIONE
- if:
condition:
lambda: "return (${relay_count}>1 && id(relay_1).state) ;"
then:
- script.execute: led_on_button_left
else:
- script.execute: led_off_button_left
- if:
condition:
lambda: "return (${relay_count}==3 && id(relay_2).state) || (${relay_count}==1 && id(relay_1).state);"
then:
- script.execute: led_on_button_middle
else:
- script.execute: led_off_button_middle
- if:
condition:
lambda: "return (${relay_count}==2 && id(relay_2).state) || (${relay_count}==3 && id(relay_3).state);"
then:
- script.execute: led_on_button_right
else:
- script.execute: led_off_button_right
- if:
condition:
lambda: "return id(nightlight_active).state;"
then:
- script.execute: led_on_nightlight
else:
- light.turn_off: leds_top
- id: led_on_button_left #DEFINISCE IL COMPORTAMENTO DEI LED DEL BOTTONE SINISTRO ALL'ACCENSIONE
mode: restart
then:
- light.turn_on:
id: leds_button_left
brightness: ${button_brightness}
red: !lambda "return id(button_color)[0]/100.0;"
green: !lambda "return id(button_color)[1]/100.0;"
blue: !lambda "return id(button_color)[2]/100.0;"
- id: led_on_button_middle #DEFINISCE IL COMPORTAMENTO DEI LED DEL BOTTONE CENTRALE ALL'ACCENSIONE
mode: restart
then:
- light.turn_on:
id: leds_button_middle
brightness: ${button_brightness}
red: !lambda "return id(button_color)[0]/100.0;"
green: !lambda "return id(button_color)[1]/100.0;"
blue: !lambda "return id(button_color)[2]/100.0;"
- id: led_on_button_right #DEFINISCE IL COMPORTAMENTO DEI LED DEL BOTTONE DESTRO ALL'ACCENSIONE
mode: restart
then:
- light.turn_on:
id: leds_button_right
brightness: ${button_brightness}
red: !lambda "return id(button_color)[0]/100.0;"
green: !lambda "return id(button_color)[1]/100.0;"
blue: !lambda "return id(button_color)[2]/100.0;"
- id: led_off_button_left #DEFINISCE IL COMPORTAMENTO DEI LED DEL BOTTONE SINISTRO ALLO SPEGNIMENTO
mode: restart
then:
- if:
condition:
lambda: "return id(nightlight_active).state;"
then:
- light.turn_on:
id: leds_button_left
brightness: ${nightlight_brightness}
red: !lambda "return id(nightlight_color)[0]/100.0;"
green: !lambda "return id(nightlight_color)[1]/100.0;"
blue: !lambda "return id(nightlight_color)[2]/100.0;"
else:
- light.turn_off:
id: leds_button_left
- id: led_off_button_middle #DEFINISCE IL COMPORTAMENTO DEI LED DEL BOTTONE CENTRALE ALLO SPEGNIMENTO
mode: restart
then:
- if:
condition:
lambda: "return id(nightlight_active).state;"
then:
- light.turn_on:
id: leds_button_middle
brightness: ${nightlight_brightness}
red: !lambda "return id(nightlight_color)[0]/100.0;"
green: !lambda "return id(nightlight_color)[1]/100.0;"
blue: !lambda "return id(nightlight_color)[2]/100.0;"
else:
- light.turn_off:
id: leds_button_middle
- id: led_off_button_right #DEFINISCE IL COMPORTAMENTO DEI LED DEL BOTTONE DESTRO ALLO SPEGNIMENTO
mode: restart
then:
- if:
condition:
lambda: "return id(nightlight_active).state;"
then:
- light.turn_on:
id: leds_button_right
brightness: ${nightlight_brightness}
red: !lambda "return id(nightlight_color)[0]/100.0;"
green: !lambda "return id(nightlight_color)[1]/100.0;"
blue: !lambda "return id(nightlight_color)[2]/100.0;"
else:
- light.turn_off:
id: leds_button_right
- id: led_on_nightlight #DEFINISCE IL COMPORTAMENTO DEI LED DELLA NIGHTLIGHT
mode: restart
then:
- light.turn_on:
id: leds_top
brightness: ${nightlight_brightness}
red: !lambda "return id(nightlight_color)[0]/100.0;"
green: !lambda "return id(nightlight_color)[1]/100.0;"
blue: !lambda "return id(nightlight_color)[2]/100.0;"
# - id: led_on_release #DEFINISCE IL COMPORTAMENTO DEI LED QUANDO VIENE RILASCIATO IL TOUCH
# mode: restart
# then:
# - light.turn_off:
# id: leds_top
- id: led_on_touch #DEFINISCE IL COMPORTAMENTO DEI LED DURANTE IL TOUCH
mode: restart
then:
- light.turn_on:
id: leds_top
brightness: ${touch_brightness}
red: !lambda "return id(touch_color)[0]/100.0;"
green: !lambda "return id(touch_color)[1]/100.0;"
blue: !lambda "return id(touch_color)[2]/100.0;"
effect: ${touch_effect}
- delay: 6s
- script.execute: refresh_led_default
- id: led_on_swipe_left #DEFINISCE IL COMPORTAMENTO DEI LED DURANTE LO SWIPE A SINISTRA
mode: restart
then:
- light.turn_on:
id: leds_top
brightness: ${swipe_left_brightness}
red: !lambda "return id(swipe_left_color)[0]/100.0;"
green: !lambda "return id(swipe_left_color)[1]/100.0;"
blue: !lambda "return id(swipe_left_color)[2]/100.0;"
effect: ${swipe_left_effect}
- id: led_on_swipe_right #DEFINISCE IL COMPORTAMENTO DEI LED DURANTE LO SWIPE A DESTRA
mode: restart
then:
- light.turn_on:
id: leds_top
brightness: ${swipe_right_brightness}
red: !lambda "return id(swipe_right_color)[0]/100.0;"
green: !lambda "return id(swipe_right_color)[1]/100.0;"
blue: !lambda "return id(swipe_right_color)[2]/100.0;"
effect: ${swipe_right_effect}
- id: led_on_full_touch #DEFINISCE IL COMPORTAMENTO DEI LED DURANTE IL MULTI TOUCH
mode: restart
then:
- light.turn_on:
id: leds_top
brightness: ${multi_touch_brightness}
red: !lambda "return id(multi_touch_color)[0]/100.0;"
green: !lambda "return id(multi_touch_color)[1]/100.0;"
blue: !lambda "return id(multi_touch_color)[2]/100.0;"
effect: ${multi_touch_effect}
- id: led_on_long_touch #DEFINISCE IL COMPORTAMENTO DEI LED DURANTE IL LONG PRESS
mode: restart
then:
- light.turn_on:
id: leds_top
brightness: ${long_press_brightness}
red: !lambda "return id(long_press_color)[0]/100.0;"
green: !lambda "return id(long_press_color)[1]/100.0;"
blue: !lambda "return id(long_press_color)[2]/100.0;"
effect: ${long_press_effect}
- id: handle_release # ATTIVA I BINARY SENSOR TOUCHFIELD 1 2 e 3.
mode: restart
parameters:
pos: int
then:
- if:
condition:
lambda: "return ${relay_count}==1;"
then:
- binary_sensor.template.publish:
id: touchfield_1
state: ON
- if:
condition:
lambda: "return ${relay_count}==2;"
then:
- if:
condition:
lambda: "return pos <= 5;"
then:
- binary_sensor.template.publish:
id: touchfield_1
state: ON
else:
- binary_sensor.template.publish:
id: touchfield_2
state: ON
- if:
condition:
lambda: "return ${relay_count}==3;"
then:
- if:
condition:
lambda: "return pos <= 3;"
then:
- binary_sensor.template.publish:
id: touchfield_1
state: ON
else:
- if:
condition:
lambda: "return pos <= 7;"
then:
- binary_sensor.template.publish:
id: touchfield_2
state: ON
else:
- binary_sensor.template.publish:
id: touchfield_3
state: ON
OK, A couple of things…
When you partition an led strip, that means your turning 1 light into 2 or more controllable lights, right?
I can see that you have no control the partitions because you set them all up to be hidden from the front end in HA.
Some of them arent set up correctly and they may not work well or work at all anyway. You’ve got a bunch of partitions and theres a warning in the documentation about doing that because of high risk you run out of memory.
Each of your problems is because you didn’t read the documentation or configure the partitions how it tells you too.
Like here, that isnt how it tells you to use (internal).
Check the documentation again. Ill help you if you cant figure it out but, every problem you have is from not setting it up like it tells you.