Hi,
I need some code assistance please.
I am looking to turn a PCF8574 on and off (linked to a light).
It runs off a D1Mini and i have it displaying what i need correctly.
So far code i have.
2c:
sda: D1
scl: D2
display:
- platform: lcd_pcf8574
id: mydisplay
dimensions: 20x4
address: 0x27
lambda: |-
it.print(8, 0, "Study");
it.printf(0, 1, "Temp: %.1f", id(tempoffice).state);
it.printf(0, 2, "Humidity: %.0f", id(temphumidity).state);
sensor:
- platform: homeassistant
id: tempoffice
name: tempoffice
entity_id: sensor.joe_s_office_temperature_2
internal: true
- platform: homeassistant
id: temphumidity
name: temphumidity
entity_id: sensor.joe_s_office_humidity
internal: true
So above works flawlessly.
I just need help if possible writing the second part of the code for ESPHome.
Below is the suggested for movement based sensor.
i just need it to turn on when my desk light is on and off when it is off. My coding is frightful.
TIA
display:
- platform: lcd_pcf8574
id: mydisplay
# ...
binary_sensor:
- platform: gpio
# ...
on_press:
then:
- binary_sensor.template.publish:
id: backlight
state: ON
- binary_sensor.template.publish:
id: backlight
state: OFF
- platform: template
id: backlight
filters:
- delayed_off: 90s
on_press:
then:
- lambda: |-
id(mydisplay).backlight();
on_release:
then:
- lambda: |-
id(mydisplay).no_backlight();