Following a recent esphome update, I noticed the following error…
[W][homeassistant.binary_sensor:017]: Can't convert 'unknown' to binary state!
I have attempted to locate the cause, but no matter what I change it doesn’t appear to affect the error?
Here’s my code…
esp8266:
board: nodemcuv2
framework:
version: recommended
esphome:
name: esp1-studio
on_boot:
- lambda: 'id(climate_id).mode = climate::CLIMATE_MODE_COOL;'
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s
ota:
password: !secret ota_password
wifi:
# use_address: testbuild.local
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "esp1_studio Fallback Hotspot"
password: "Redacted"
captive_portal:
# MQTT Interface
mqtt:
broker: !secret mqtt_broker
port: 1883
reboot_timeout: 0s
keepalive: 60s
discovery: false
on_message:
- topic: HomeAssistant/Studio/Aircon/Status
payload: "OFF"
qos: 0
then:
- binary_sensor.template.publish:
id: ac_status
state: off
- logger.log: "The AC is OFF"
- topic: HomeAssistant/Studio/Aircon/Status
payload: "ON"
qos: 0
then:
- binary_sensor.template.publish:
id: ac_status
state: on
- logger.log: "The AC is ON"
status_led:
pin: GPIO2
# Studio door reed switch sensor.
binary_sensor:
# AC status
- platform: template
id: ac_status
on_press:
- binary_sensor.template.publish:
id: climate_status
state: off
on_release:
- binary_sensor.template.publish:
id: climate_status
state: on
- platform: template
id: climate_status
on_press:
- climate.control:
id: climate_id
mode: 'cool'
- switch.turn_on: damper_sw
on_release:
- climate.control:
id: climate_id
mode: 'off'
- switch.turn_off: damper_sw
# Studio Air Conditioner Status from HA
- platform: homeassistant
id: studio_ac_climate
name: "Studio AC Status from HA"
entity_id: binary_sensor.studio_ac_climate
#Temperature Sensor Pin
dallas:
- pin: D1
update_interval: 30s
#Relay switches
switch:
- platform: gpio
pin:
number: D6
inverted: True
id: damper_sw
name: "damper_sw"
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin:
number: D5
inverted: True
id: fan_sw
name: "fan_sw"
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin:
number: D7
inverted: True
id: rackfan_sw
name: "rackfan_sw"
restore_mode: RESTORE_DEFAULT_OFF
# Restart
- platform: restart
name: "esp1 Studio Restart"
sensor:
# Studio Outside DHT11 Sensor
- platform: dht
model: DHT11
pin: D2
temperature:
name: "Studio DHT Out Temp"
id: studio_dht_out_temp
humidity:
name: "Studio DHT Humidity"
update_interval: 30s
# Studio Inside temperature sensor
- platform: dallas
id: in_dallas_id
resolution: 12
address: 0x1101143025227D28
name: studio_in_temp
# Studio Outside temperature sensor
# - platform: dallas
# id: out_dallas_id
# resolution: 12
# address: 0xE602131B13F9AA28
# name: studio_out_temp
on_value:
then:
- if:
condition:
and:
# Is the outside temp below 19 and the AC off
- binary_sensor.is_off: studio_ac_climate
- lambda: 'return id(studio_dht_out_temp).state < 19;'
then:
# Open the damper
- binary_sensor.template.publish:
id: climate_status
state: on
- mqtt.publish:
topic: HomeAssistant/Studio/Damper/Status
payload: "1"
- logger.log: "The damper and climate is active"
- if:
condition:
or:
# Is the outside temp above 19 or the AC on
- binary_sensor.is_on: ac_status
- lambda: 'return id(studio_dht_out_temp).state > 19;'
then:
- binary_sensor.template.publish:
id: climate_status
state: off
- mqtt.publish:
topic: HomeAssistant/Studio/Damper/Status
payload: "0"
- logger.log: "The damper and climate is off"
climate:
- platform: thermostat
min_idle_time: 30s
min_cooling_off_time: 120s
min_cooling_run_time: 120s
name: "Studio Climate Controller"
id: climate_id
sensor: in_dallas_id
default_target_temperature_high: 22 °C
cool_action:
- switch.turn_on: fan_sw
- logger.log: "The fan is now on"
- mqtt.publish:
topic: HomeAssistant/Studio/Fan/Status
payload: "1"
idle_action:
- switch.turn_off: fan_sw
- logger.log: "The fan is now off"
- mqtt.publish:
topic: HomeAssistant/Studio/Fan/Status
payload: "0"
Please forgive my rubbish coding… it has been working successfully for quite some time now.
Any suggestions greatly appreciated.