odya / hass-ina219-ups-hat

Home Assistant UPS Hat integration. Waveshare and others based on INA219
MIT License
11 stars 2 forks source link

Error while setting up ina219_ups_hat platform for sensor #6

Closed tiimsvk closed 3 months ago

tiimsvk commented 10 months ago

Hi, when I installed the addon to HA and added the sensors to the configuration, the log says this. Where is the problem? well thank you

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:359
Integration: Senzor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 14:26:38 (1 occurrences)
Last logged: 14:26:38
Error while setting up ina219_ups_hat platform for sensor

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/ina219_ups_hat/sensor.py", line 57, in async_setup_platform
    coordinator = INA219UpsHatCoordinator(hass, config)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ina219_ups_hat/coordinator.py", line 29, in __init__
    self._ina219 = INA219(addr=0x41)
                   ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ina219_ups_hat/ina219.py", line 70, in __init__
    self.set_calibration_32V_2A()
  File "/config/custom_components/ina219_ups_hat/ina219.py", line 153, in set_calibration_32V_2A
    self.write(_REG_CALIBRATION,self._cal_value)
  File "/config/custom_components/ina219_ups_hat/ina219.py", line 80, in write
    self.bus.write_i2c_block_data(self.addr,address,temp)
  File "/usr/local/lib/python3.11/site-packages/smbus2/smbus2.py", line 643, in write_i2c_block_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error

I enabled the i2c interface according to this: https://www.home-assistant.io/common-tasks/os/#enable-i2c

tiimsvk commented 10 months ago

change adresse 40 self._ina219 = INA219(addr=0x40) solved me problem

HittyStorm commented 9 months ago

Same error for me. But changing address to 0x40 did not help. Any suggestions how to find actual address without installing a toons of addons? I use HASSOS.

P.S. Looks like my address is 0x42, but now I see a bunch of errors... And the sensor was created, but not available.

Error doing job: Task exception was never retrieved 15:17:21 – (ERROR) ina219_ups_hat (custom integration) - message first occurred at 15:17:20 and shows up 2 times Error while setting up ina219_ups_hat platform for binary_sensor 15:17:20 – (ERROR) Binary Sensor Error adding entities for domain binary_sensor with platform ina219_ups_hat 15:17:20 – (ERROR) Binary Sensor Error adding entities for domain sensor with platform ina219_ups_hat 15:17:20 – (ERROR) Sensor Error while setting up ina219_ups_hat platform for sensor 15:17:20 – (ERROR) Sensor Error fetching ina219_ups_hat data: Error updating data: type NoneType doesn't define round method 15:17:20 – (ERROR) ina219_ups_hat (custom integration)

MichaelLinki commented 8 months ago

Hi together, I have the same problems. Changing to adress 0x42 created the sensors but "not available". Testing the UPS Hat with "normal" OS on another Raspi with the waveshare Demo code gives the right output. Any idea?

marcsauter75 commented 6 months ago

My error is a little bit different:

Error while setting up ina219_ups_hat platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform await asyncio.shield(awaitable) File "/config/custom_components/ina219_ups_hat/sensor.py", line 57, in async_setup_platform coordinator = INA219UpsHatCoordinator(hass, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ina219_ups_hat/coordinator.py", line 29, in init self._ina219 = INA219(addr=0x41) ^^^^^^^^^^^^^^^^^ File "/config/custom_components/ina219_ups_hat/ina219.py", line 63, in init self.bus = smbus.SMBus(i2c_bus); ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/smbus2/smbus2.py", line 280, in init self.open(bus) File "/usr/local/lib/python3.12/site-packages/smbus2/smbus2.py", line 310, in open self.fd = os.open(filepath, os.O_RDWR) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'

some ideas ?

csadams commented 4 months ago

Thanks to everyone who chimed in on this error, I was seeing the same thing. Took me a while to figure out which file the line "self._ina219 = INA219(addr=0x41)" was in: homeassistant/custom_components/ina219_ups_hat/coordinator.py. For me, changing from 0x41 to 0x40 (and restarting hass) didn't help, but 0x42 did the trick. Hopefully this helps makes it easier for others to solve.

e3e6 commented 4 months ago

If you check the "HassOS I2C Configurator" add-on log you can see available I2C devices:

brw-rw----    1 root     disk      254,   2 Jan 25 00:45 zram2
/dev/i2c-1
/dev/i2c-0 /dev/i2c-1 /dev/i2c-10 /dev/i2c-22
Found i2c access!  Nothing to do!  You can remove this add-on
odya commented 3 months ago

I'll move addr option to config