Coder Social home page Coder Social logo

racailloux / home-assistant-pijuice Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 3.0 93 KB

Home Assistant integration to support PiJuice UPS Hat and retrieve values to sensors.

License: Apache License 2.0

Python 100.00%
battery hat home-assistant integrations pijuice raspberry-pi sensors ups voltage

home-assistant-pijuice's People

Contributors

lcnittl avatar logan893 avatar misa1515 avatar racailloux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

home-assistant-pijuice's Issues

Device class None, state class and unit None

This is logged on every reboot:

Logger: homeassistant.components.sensor
Source: components/sensor/init.py:597
Integration: Sensor (documentation, issues)
First occurred: 12:45:59 (2 occurrences)
Last logged: 12:45:59

Sensor sensor.pijuice_battery_status has device class None, state class and unit None thus indicating it has a numeric value; however, it has the non-numeric value: normal (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.
Sensor sensor.pijuice_power_input_io_status has device class None, state class and unit None thus indicating it has a numeric value; however, it has the non-numeric value: present (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

PiJuice IO current to high ?

Setup : Rpi 3b
Power connected to Pijuice direct.
battery : 12000 mAh
power supply 2.5 A
latest version of your excellent Hacs plugin

I choose the right battery config , ( with booting into normal pi OS

All works correct except PiJuice IO current is way to high, when charging is between 9 A and 206 A
when running on Batterij juice alone it is between 12 A and 250 A.
I there another setting in the Pjuice config i should change ( i left everything on default value except the battery type ( setting for 12000 mAh.
Or is there a error in your code that puts the "." wrong ?

Lot of errors in logs

PiJuice integration writes this kind of errors into log quite often (5897 times in less than 2 days in example below).
However, in most times the PiJuice integration gets all the values, I guess.

Maybe some error handling should be enhanced?
If falue_not_got, try again (or skip and try again next time), or something.


This error originated from a custom integration.

Logger: homeassistant.helpers.entity
Source: custom_components/pijuice/sensor.py:192
Integration: pijuice (documentation, issues)
First occurred: June 9, 2021, 16:58:55 (5897 occurrences)
Last logged: 13:23:29

Update for sensor.pijuice_io_current fails
Update for sensor.pijuice_battery_status fails
Update for sensor.pijuice_power_input_status fails
Update for sensor.pijuice_power_input_io_status fails
Update for sensor.pijuice_charge fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 350, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 558, in async_device_update
raise exc
File "/config/custom_components/pijuice/sensor.py", line 192, in async_update
data = bus.read_i2c_block_data(i2c_address, self._index, self._size)
File "/usr/local/lib/python3.8/site-packages/smbus2/smbus2.py", line 617, in read_i2c_block_data
ioctl(self.fd, I2C_SMBUS, msg)
TimeoutError: [Errno 110] Operation timed out

Deprecated constants

These error messages are shown in logs in HA Core 2024.1.x

TEMP_CELSIUS was used from pijuice, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfTemperature.CELSIUS instead, please create a bug report at https://github.com/Racailloux/home-assistant-pijuice/issues
TEMP_FAHRENHEIT was used from pijuice, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfTemperature.FAHRENHEIT instead, please create a bug report at https://github.com/Racailloux/home-assistant-pijuice/issues
ELECTRIC_POTENTIAL_VOLT was used from pijuice, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfElectricPotential.VOLT instead, please create a bug report at https://github.com/Racailloux/home-assistant-pijuice/issues
ELECTRIC_CURRENT_AMPERE was used from pijuice, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfElectricCurrent.AMPERE instead, please create a bug report at https://github.com/Racailloux/home-assistant-pijuice/issues

STATE_CLASS_MEASUREMENT was used from pijuice, this is a deprecated constant which will be removed in HA Core 2025.1. Use SensorStateClass.MEASUREMENT instead, please create a bug report at https://github.com/Racailloux/home-assistant-pijuice/issues

Seeking documentation to explain the sensors

I have successfully enabled I2C on a standard HA installation and used HACS to install your code.
I have all the sensors reporting values but I do not understand what the values are telling me.
Is there something written up about them?

pijuice

Since HA core-2021.8.0 plugin does not work anymore

Hi Racailloux,

I run HA core on a Raspberry Pi 4

Your plugin worked beautiful until i upgraded to HA Core Version core-2021.8.0 .
All the entities are "' not available".
I rebooted the Pi , did not help either.

The error log is
`This error originated from a custom integration.

Logger: homeassistant.config
Source: custom_components/pijuice/sensor.py:12
Integration: pijuice (documentation, issues)
First occurred: 19:00:01 (1 occurrences)
Last logged: 19:00:01

Platform error: sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config.py", line 857, in async_process_component_config
platform = p_integration.get_platform(domain)
File "/usr/src/homeassistant/homeassistant/loader.py", line 498, in get_platform
cache[full_name] = self._import_platform(platform_name)
File "/usr/src/homeassistant/homeassistant/loader.py", line 503, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File "/usr/local/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 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/config/custom_components/pijuice/sensor.py", line 12, in
from homeassistant.const import (
ImportError: cannot import name 'VOLT' from 'homeassistant.const' (/usr/src/homeassistant/homeassistant/const.py)

I upgraded to HA Core Version core-2021.8.0 today and that did not fix it

Could you have a look ?

Regards

Karel

Mistake, already fixed

Breaking pijuice since HA 2023.11
https://developers.home-assistant.io/blog/2023/10/03/conversion-functions-cleanup/

2023-12-21 02:43:54.773 ERROR (MainThread) [homeassistant.config] Platform error: sensor - No module named 'homeassistant.util.temperature'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config.py", line 1380, in async_process_component_config
platform = p_integration.get_platform(domain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 834, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 851, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/config/custom_components/pijuice/sensor.py", line 12, in
from homeassistant.util.temperature import celsius_to_fahrenheit
ModuleNotFoundError: No module named 'homeassistant.util.temperature'

Already fixed, just not mentioned clearly enough at first glance in the release notes.

Two sensors missing after HA update to 2023.5.0

After update to Home Assistant 2023.5.0 the sensors pijuice_battery_status and pijuice_power_input_io_status are no longer available. The other PiJuice entities are still available. Not using HACS, manual install through configuration.yaml.

cannot import name 'SensorEntity' from 'homeassistant.components.sensor'

Hi,

First, thanks for putting this together!

I manually added the files as per your instructions. And when validating configurations prompted the following error:

Platform error sensor.pijuice - cannot import name 'SensorEntity' from 'homeassistant.components.sensor' (/usr/src/homeassistant/homeassistant/components/sensor/init.py)

5049965E-5992-40E4-BA1B-915AF43AB0B9
E57B6479-D40E-42CF-9ACE-C24EF588C350

What am I doing wrong? Please advise

Thanks
Val

Apparent null ref on setup

Logs below. I'm not a python guy (I hate significant whitespace), but I assume that self._attr_native_value is null, which means it's not being set somehow.

HA version 2024.2.2

I2C is confirmed to be enabled.

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:533
Integration: Sensor (documentation, issues)
First occurred: 10:01:30 AM (1 occurrences)
Last logged: 10:01:30 AM

Error adding entities for domain sensor with platform pijuice
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 533, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 782, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1325, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 989, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1110, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1071, in __async_calculate_state
    shadowed_attr[ATTR_ICON] = self.icon
                               ^^^^^^^^^
  File "/config/custom_components/pijuice/sensor.py", line 195, in icon
    if self._attr_native_value > 90:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int'

Also getting this:

This error originated from a custom integration.

Logger: custom_components.pijuice.sensor
Source: custom_components/pijuice/sensor.py:244
Integration: pijuice (documentation, issues)
First occurred: 10:01:22 AM (9 occurrences)
Last logged: 10:01:30 AM

PiJuice: Error while retrieving data for sensor 'Temperature' (Error code: '[Errno 110] Operation timed out')
PiJuice: Error while retrieving data for sensor 'Battery voltage' (Error code: '[Errno 110] Operation timed out')
PiJuice: Error while retrieving data for sensor 'Battery current' (Error code: '[Errno 110] Operation timed out')
PiJuice: Error while retrieving data for sensor 'IO voltage' (Error code: '[Errno 110] Operation timed out')
PiJuice: Error while retrieving data for sensor 'IO current' (Error code: '[Errno 110] Operation timed out')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.