I want to make a Solar boiler project to store PV energy in a boiler.
In HA I have made a sensor named Dump Current.
The goal is to have a PWM output that is mapped to a range of current (Amps) value.
When compiling the code I get the error below:
Lambda contains reference to entity-id-style ID ‘sensor.dump_current’ ‘sensor.dump_current’ ‘sensor.dump_current’ ‘sensor.dump_current’. The id() wrapper only works for ESPHome-internal types. For importing states from Home Assistant use the ‘homeassistant’ sensor platforms.
esphome:
name: boiler
comment: boiler heater with solar energy (dump current)
platform: esp8266
board: d1_mini
on_boot:
priority: 0
then:
- output.set_level:
id: pwm_output
level: 0
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
captive_portal:
dallas:
- pin: GPIO0
update_interval: 1s
globals:
- id: pwm_off
type: int
restore_value: no
initial_value: '0'
- id: min_pwm_value
type: int
restore_value: no
initial_value: '30'
- id: actual_pwm_value
type: int
restore_value: no
initial_value: '0'
- id: max_pwm_value
type: int
restore_value: no
initial_value: '255'
- id: temp_start_heating
type: float
restore_value: no
initial_value: '56.0'
- id: temp_stop_heating
type: float
restore_value: no
initial_value: '60.0'
- id: min_current
type: float
restore_value: no
initial_value: '1.0'
- id: max_current
type: float
restore_value: no
initial_value: '5.0'
sensor:
- platform: dallas
address: 0x280008037073a910
name: "DS18B20 Sensor" ## THIS SENSOR MEASURES THE WATER TEMPERATURE IN THE BOILER
id: boiler_temp
- platform: wifi_signal
name: ${friendly_name} Signal
update_interval: 60s
- platform: homeassistant
name: "Dump Current HA"
entity_id: sensor.dump_current
accuracy_decimals: 1
output:
- platform: esp8266_pwm
pin: GPIO16
frequency: 10000Hz
id: pwm_output
inverted: true
- platform: template
id: pwm_output
type: float
write_action:
- output.set_level:
id: pwm_output
level: !lambda |-
if ((id(sensor.dump_current) > 1) && (state) < id(max_pwm_value
{
id(actual_pwm_value) +=1;
### Map new value##
return ((id(sensor.dump_current) - (id(min_current)) * ((id(max_pwm_value) - (id(min_pwm_value) / (id(max_current_current) - id(min_current)) + (id(min_pwm_value);
}
else if ((id(sensor.dump_current) < 1)
{
id(actual_pwm_value) -=1;
### Map new value##
return ((id(sensor.dump_current) - (id(min_current)) * ((id(max_pwm_value) - (id(min_pwm_value) / (id(max_current_current) - id(min_current)) + (id(min_pwm_value);
}
else
{
return 0;
}