tfyoung / esphome-junctek_kgf

Component for esphome to read status from a Junctek KG-F coulometer/battery monitor via UART
MIT License
24 stars 14 forks source link

TypeError when compiling #1

Closed ckloeti closed 2 years ago

ckloeti commented 2 years ago

Hello tfyoung, many thanks for programming this esphome sensor integration for Junctek battery monitor. A I try to compile it it gives me following error: INFO Reading configuration /config/esphome/yucon-battery-monitor.yaml... ERROR Unable to load component junctek_kgf.sensor: 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 "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "/config/esphome/.esphome/external_components/9c6cd628/components/junctek_kgf/sensor.py", line 54, in cv.Optional(CONF_VOLTAGE): sensor.sensor_schema( TypeError: sensor_schema() takes from 0 to 1 positional arguments but 5 were given Failed config

sensor.junctek_kgf: [source /config/esphome/yucon-battery-monitor.yaml:18]

Platform not found: 'sensor.junctek_kgf'. platform: junctek_kgf address: 1 voltage: name: Battery Voltage current: name: Battery Current battery_level: name: Battery Level temperature: name: Battery Temperature

the config I use is the one provides as example:

external_components:

uart: tx_pin: 1 rx_pin: 3 baud_rate: 115200

sensor:

Are you able to help me as my programming skills are not so good to fix this issue.

Many thanks Christoph

ckloeti commented 2 years ago

Hi, I changed sensor.py to be working now sensor.zip .

tfyoung commented 2 years ago

Thanks for reporting this. I've been meaning to fix this having had the issue come up on another integration i'm working on (I haven't updtated my junktek for a while to hit this for this module). I'll push a fix for it soon, though if you wanted to take your changes and make a pull request for them, I'd gladly merge.

tfyoung commented 2 years ago

This should be fixed now with the most recent commit to main

ckloeti commented 2 years ago

Many thanks tfyoung