Hello together,
I’ve been dealing with HS for a few weeks now. I’m also using EspHome and now I’m currently at a point where I don’t know how to go further with my EspHome project.
I use an RF remote to control my “floor lamp.” With a short press of the remote button, I turn the WLEDs on/off, and with a long press, I dim the lamp up/down. Everything works almost as I imagined. There’s still one small thing missing and I want to find a solution for that.
My problem is that I only want to dim the light when the current brightness is above 11%. I want to prevent the light from being turned OFF via a dimming process. But I don’t know how to access the lamp’s data to make this happen.
The following lines are part of my .yaml file that is responsible for dimming down via the remote button:
- platform: remote_receiver
id: "rf_remote_4_off"
name: "Button [4] OFF"
rc_switch_raw:
protocol: 2
code: '011011001001001110100111101011101111xxxx'
# set filter to eliminate bouncing
filters:
- delayed_off: 100ms
# when a rising edge has been detected
on_press:
then:
# wait to decide for a long or short press
- delay: 250ms
- if:
# has the button already been released...
condition:
binary_sensor.is_off: rf_remote_4_off
# ... then it was a short press
then:
- logger.log: "short press => off"
- homeassistant.service:
service: light.turn_off
data:
entity_id: light.lamp
# otherwise, it was a long press
else:
while:
condition:
binary_sensor.is_on: rf_remote_4_off
then:
- logger.log: "long press => dimming down"
- homeassistant.service:
service: light.turn_on
data:
brightness_step_pct: '-10'
entity_id: light.lamp
# dimming steps
- delay: 500ms
I tried a lot with the templates (Lambda), but none of it worked.
I understand that I can get access to the lamp’s entities from HA via “- homeassistant.service:” command. But I did not find any solution to handle my problem.
So, I would need the ability to evaluate the current brightness value of my floor lamp to then decide whether or not to dim it further. I don’t have a unique entity for the floor lamp that provides me with a brightness value.
Something like that:
If( id(lamp).brightness > 11) {
brightness_step_pct: '-10'
}
As I said, I assume that the best way to do this is with a lambda statement.
The second question I have is how I can output the brightness entity to the log.
For Lambda, there’s “ESP_LOGD:,” but I’m missing the “data point” and how to even get it into Lambda. (That’s also my first problem.)
Could someone give me a hint on how I get the brghtness data from my floor lamp into my EspHome?