Hi,
I’m trying to create a simple rain detection sensor that basically acts as a switch to help home assistant decide whether it should skip spraying my garden with dipel on a rainy day as it will likely wash off.
I’m simplifying the project found here
I have a pcb with traces on it connected to a weemos d1 mini with a reference resistor. I’m trying to convert the resistance to a simple on (wet) or off (dry) message but get the following compile error " Unable to find action with the name ‘sensor.template.publish’. sensor.template.publish: [source /config/esphome/rain-sensor.yaml:57] id: real_resistance_sensor state: !lambda |- return ON; "
I’ve had it working previously but had to rewrite the code from scratch and cant figure out what I’m doing wrong. As far as i could read in the docs sensor.template.publish action still exists?
**Any help would be appreciated
Below is my code
esphome:
name: rain-sensor
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Rain-Sensor Fallback Hotspot"
password: !secret ap_password
captive_portal:
switch:
- platform: gpio
pin: D0
name: "Rain sensor powerr"
sensor:
- platform: adc
id: source_sensor
pin: A0
- platform: resistance
icon: "mdi:omega"
internal: true
sensor: source_sensor
configuration: DOWNSTREAM
resistor: 5.1kOhm
reference_voltage: 3.3
name: "${friendly_name} rain"
id: real_resistance_sensor
on_value:
then:
- if:
condition:
lambda: |-
return (
id(real_resistance_sensor).state > 100
);
then:
- sensor.template.publish:
id: real_resistance_sensor
state: !lambda 'return ON;'