esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

ESPHome 2022.3.0 Sensor component error #3172

Closed nic6911 closed 2 years ago

nic6911 commented 2 years ago

The problem

Hi,

I have an external component for a floor heating system which worked just fine prior to the 2022.3.0 release of ESPHome. Now however it fails... Seems like there is an error with the Sensor component ?

Any good advice on how to get around this?

Br, Mogens

Which version of ESPHome has the issue?

2022.3.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2022.3.5

What platform are you using?

ESP8266

Board

ESP-01

Component causing the issue

Sensor

Example YAML snippet

########################################################################################
#                                                                                      #
#      WAVIN AHC-9000 FLOOR HEATING CONTROLLER SOFTWARE FOR HOME ASSISTANT             #
#                                                                                      #   
#        Code developed by : Heine Koldbro Madsen and Samuel Sieb 2021                 #
#                                                                                      #
# https://github.com/heinekmadsen/esphome_components/tree/main/components/wavinAhc9000 #    
#                                                                                      #
# Hardware by : Mogens Groth Nicolaisen https://github.com/nic6911/Wavin-AHC-9000-mqtt #                                                                                       #
#                                                                                      #
########################################################################################

########################################################################################
#                      CONFIGURATION PART OF YOUR CHOICE :)                            #
########################################################################################

substitutions:
  device_name: 'wavin'
  friendly_name: 'Wavin'
  log_level: DEBUG

  # UPDATE TIME (GATEWAY)
  update_interval: 60s

  # CHANNEL ID´S
  channel_1:  Room 1

  # TEMP STEP + CLIMATE MIN/MAX LIMIT TEMP SETPOINT
  temp_step:   '0.5'
  climate_min_temp: '12'  
  climate_max_temp: '40'

  # PIN DEFINITIONS (Should in most cases not be changed) 
  tx_enable_pin: '2'
  rx_pin: RX
  tx_pin: TX

  # WiFi settings
  ssid_set: "My Wi-Fi Network"
  password_set: "password"

########################################################################################
#                        CODE BELOW SHOULD NOT BE CHANGED                              #
########################################################################################  

esphome:
  name: ${device_name}
  platform: ESP8266
  board: esp01_1m
  project:
    name: "home.wavin_gulvvarme"
    version: "1.0.0"

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:

ota:
  password: "945ac67ddcae11048f6a488672b6aadb"

wifi:
  ssid: ${ssid_set}
  password: ${password_set}

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wavin Fallback Hotspot"
    password: "12345678"

captive_portal:  

uart:
  rx_pin: ${rx_pin}
  tx_pin: ${tx_pin}
  baud_rate: 38400
  id: uart_modbus
  stop_bits: 1

external_components:
  - source: github://heinekmadsen/esphome_components

# Temporary fix for modbus component error in ESPHome 2021.10.0
# https://github.com/esphome/issues/issues/2630
# Might not be nessesary in future builds, but for now it is
  - source:
      type: git
      url: https://github.com/martgras/esphome
      ref: modbus-fix
    components: [ modbus ]

modbus:
  uart_id: uart_modbus

wavinAhc9000:
  update_interval: ${update_interval}
  rw_pin: ${tx_enable_pin}

climate:
  - platform: wavinAhc9000
    channel: 1
    name: ${friendly_name} Climate ${channel_1}
    battery_level:
      name: ${friendly_name} Battery ${channel_1}
    current_temp:
      name: ${friendly_name} Temp ${channel_1}
    visual:
      temperature_step: ${temp_step} °C
      min_temperature: ${climate_min_temp} °C
      max_temperature: ${climate_max_temp} °C

Anything in the logs that might be useful for us?

ERROR Unable to load component wavinAhc9000.climate:
Traceback (most recent call last):
  File "/esphome/esphome/loader.py", line 162, in _lookup_module
    module = importlib.import_module(f"esphome.components.{domain}")
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/esphome/.esphome/external_components/929b1051/components/wavinAhc9000/climate/__init__.py", line 29, in <module>
    cv.Optional(CONF_BATTERY_LEVEL): sensor.sensor_schema(UNIT_PERCENT, ICON_PERCENT, 0, DEVICE_CLASS_BATTERY),
TypeError: sensor_schema() takes from 0 to 1 positional arguments but 4 were given

Additional information

No response

nic6911 commented 2 years ago

A change in the sensor component causes this, a change had to be made in the climate init.py of the custom component for Wavin from this: CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(WavinAhc9000Climate), cv.GenerateID(CONF_WAVINAHC9000_ID): cv.use_id(WavinAhc9000), cv.Required(CONF_CHANNEL): cv.int_range(min=1, max=16), cv.Optional(CONF_BATTERY_LEVEL): sensor.sensor_schema(unit_of_measurement=UNIT_PERCENT, icon=ICON_PERCENT, device_class=DEVICE_CLASS_BATTERY), cv.Optional(CONF_CURRENT_TEMP): sensor.sensor_schema(unit_of_measurement=UNIT_CELSIUS, icon=ICON_THERMOMETER, device_class=DEVICE_CLASS_TEMPERATURE), }).extend(cv.COMPONENT_SCHEMA) To this: CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(WavinAhc9000Climate), cv.GenerateID(CONF_WAVINAHC9000_ID): cv.use_id(WavinAhc9000), cv.Required(CONF_CHANNEL): cv.int_range(min=1, max=16), cv.Optional(CONF_BATTERY_LEVEL): sensor.sensor_schema(UNIT_PERCENT, ICON_PERCENT, 0, DEVICE_CLASS_BATTERY), cv.Optional(CONF_CURRENT_TEMP): sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1, DEVICE_CLASS_TEMPERATURE, CONF_STATE_CLASS), }).extend(cv.COMPONENT_SCHEMA)

I'll mark the issue as closed, as I expect that this was an intended change to the sensor component.