toast
(Toast)
June 29, 2018, 10:14am
21
lets see if this works for hass.io (note all hass.io needs is a kernel bump to 4.14+ and this will work)
- platform: command_line
name: 'System: undervoltage status'
command: 'cat /sys/devices/platform/soc/soc:firmware/get_throttled'
scan_interval: 120
- platform: template
sensors:
check_charger:
friendly_name: "System: Charger"
value_template: >
{% if is_state("sensor.system_undervoltage_status", "0") -%}
No throttling detected
{% elif regex_match(states("sensor.system_undervoltage_status"), "40005", ignorecase=FALSE) or
regex_match(states("sensor.system_undervoltage_status"), "50005", ignorecase=FALSE) -%}
Throttling detected {{ states("sensor.system_number_of_undervoltage_messages") }} {{ state_attr("sensor.system_number_of_undervoltage_messages", "unit_of_measurement") }}
{% else -%}
There is a problem with your power supply or system, state {{ states("sensor.system_undervoltage_status") }} reported
{%- endif %}
metbril
(Robert ๐ณ๐ฑ๐ช๐บ)
June 29, 2018, 10:15am
22
If thatโs a file, the a file sensor or โcat, grep and wcโ. could make this work.
However, typing
~ ls -la /sys/devices/platform/soc/soc:firmware
shows that there is no get_throttled
file.
Does this imply that there is not throttling?
metbril
(Robert ๐ณ๐ฑ๐ช๐บ)
June 29, 2018, 10:16am
23
Here is some documentation:
opened 02:07PM - 04 Feb 18 UTC
closed 09:37PM - 27 Mar 18 UTC
I've been reminded that inadequate power supplies continous to be a problem for Raspberry Pi users (and even seasoned ones can...
toast
(Toast)
June 29, 2018, 10:16am
24
check the path again
/sys/devices/platform/soc/soc:firmware/get_throttled
metbril
(Robert ๐ณ๐ฑ๐ช๐บ)
June 29, 2018, 10:18am
25
cat: canโt open โ/sys/devices/platform/soc/soc:firmware/get_throttledโ: No such file or directory
metbril
(Robert ๐ณ๐ฑ๐ช๐บ)
June 29, 2018, 10:38am
27
Round robin to a GitHub issue
opened 10:35AM - 29 Jun 18 UTC
closed 01:28PM - 29 Jun 18 UTC
This will enable the use of file
/sys/devices/platform/soc/soc:firmware/get_throttled
that makes it possible to work around the lack of vcgencmd get_throttled being available.
In turn,...
1 Like
toast
(Toast)
June 29, 2018, 1:37pm
28
seems that HassOS is gonna be the new default os
metbril
(Robert ๐ณ๐ฑ๐ช๐บ)
June 29, 2018, 1:39pm
29
Yep. And the README page says
Linux kernel 4.14 (LT)
toast
(Toast)
June 30, 2018, 5:47pm
30
trying this 2 sensors instead of three and just using 4.14 since its gonna be LTS anyways
- platform: command_line
name: 'System: Charger'
command: cat /sys/devices/platform/soc/soc:firmware/get_throttled
scan_interval: 120
value_template: >
{% if value == '0' %}
No throttling detected
{% elif value == '40005' %}
Throttling detected {{ states("sensor.system_number_of_undervoltage_messages") }} {{ state_attr("sensor.system_number_of_undervoltage_messages", "unit_of_measurement") }}
{% elif value == '50005' %}
Throttling detected {{ states("sensor.system_number_of_undervoltage_messages") }} {{ state_attr("sensor.system_number_of_undervoltage_messages", "unit_of_measurement") }}
{% else %}
There is a problem with your power supply or system, state {{ value }} reported
{% endif %}
- platform: command_line
name: 'System: number of undervoltage messages'
command: "dmesg | grep Under-voltage | wc -l"
unit_of_measurement: 'times'
scan_interval: 120
feel free to comment and feedback and thank you @Tinkerer
2 Likes
metbril
(Robert ๐ณ๐ฑ๐ช๐บ)
June 30, 2018, 5:54pm
31
You can combine the โelifโ statements in one โorโ.
toast
(Toast)
July 1, 2018, 8:19am
32
yepp i know, planning on adding more statuses
0: under-voltage (0xX0001)
1: arm frequency capped (0xX0002 or 0xX0003 with under-voltage)
2: currently throttled (0xX0004 or 0xX0005 with under-voltage)
16: under-voltage has occurred (0x1000X)
17: arm frequency capped has occurred (0x2000X or 0x3000X also under-voltage occurred)
18: throttling has occurred (0x4000X or 0x5000X also under-voltage occurred)
if regex in jinja2 works the same as regular regexp this will work
- platform: command_line
name: 'System: Charger'
command: cat /sys/devices/platform/soc/soc:firmware/get_throttled
scan_interval: 120
value_template: >
{% if value == '0' %}
No throttling detected
{% elif value | regex_match(value, '[01]0001', ignorecase=False ) %}
A under-voltage has occurred
{% elif value | regex_match(value, '[23]000[23]', ignorecase=False ) %}
ARM frequency capped has with under-voltage
{% elif value | regex_match(value, '[45]000[45]', ignorecase=False ) %}
CPU is throttled due to under-voltage
{% else %}
There is a problem with your power supply or system, state {{ value }} reported
{% endif %}
does this look correct @metbril and @Tinkerer ?
metbril
(Robert ๐ณ๐ฑ๐ช๐บ)
July 1, 2018, 5:31pm
33
This is getting so enhanced that we should start considering a new component or adding it to the system info component.
1 Like
toast
(Toast)
July 2, 2018, 5:44am
34
well i am planning to do a real python component instead but in the meantime this will have todo
see opening post for link
something like this perhaps gonna check with @ludeeus if this is correct not a python coder at all will add it to opening post if its stable
@Vasiley if you care to try it out there is a python script available you said to ping ya once something was available
2 Likes
toast
(Toast)
July 2, 2018, 12:49pm
35
first custom_component added to opening post incase HassOS or Hassbian users wanna test it
1 Like
Tinkerer
(aka DubhAd on GitHub)
July 6, 2018, 5:42pm
36
The 4 value for throttling could be because of thermal issues - worth confirming that. Iโd guess that the 2 value is likely something similar.
Tinkerer
(aka DubhAd on GitHub)
July 6, 2018, 9:36pm
38
I think you posted in the wrong threadโฆ
toast
(Toast)
July 8, 2018, 11:48am
40
version 0.0.4 is up, links in opening post
1 Like
hi,
i am trying to run it but i get the following error in Homeassistant
Error doing job: Task exception was never retrieved
10:56 loader.py (ERROR)
i am on kernel 4.14
4.14.54-v7+
and Running 0.73.1 version of HA on hassbian
i tried both to put rpi_power.py under
/home/homeassitant/.homeassistant/custom_components
and/or
/home/homeassitant/.homeassistant/custom_components/sensor
for sure i am doing something wrong: can someone help?
I am new to custom components: should they be activated somewhere in HA?