home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.62k stars 29.93k forks source link

apcupsd sensor for "endapc" wrong #52293

Closed nicx closed 2 years ago

nicx commented 3 years ago

The problem

When using the apcupsd integration with sensor "end apc" I get the error:

2021-06-29 09:59:24 WARNING (SyncWorker_6) [homeassistant.components.apcupsd.sensor] Sensor type: endapc does not appear in the APCUPSd status output

Regarding the apcupsd manual the sensor is "end apc" and not "endapc". see http://www.apcupsd.org/manual/manual.html

the output of apcaccess reports correctly the documented status of "end apc":

root@nas:~# apcaccess
APC      : 001,034,0815
DATE     : 2021-06-29 10:03:26 +0200  
HOSTNAME : nas
VERSION  : 3.14.14 (31 May 2016) slackware
UPSNAME  : nas
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2021-06-28 16:13:58 +0200  
MODEL    : Back-UPS ES 700G 
STATUS   : ONLINE 
LINEV    : 232.0 Volts
LOADPCT  : 16.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 6.9 Minutes
MBATTCHG : 10 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Medium
LOTRANS  : 180.0 Volts
HITRANS  : 266.0 Volts
ALARMDEL : No alarm
BATTV    : 13.5 Volts
LASTXFER : Low line voltage
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000008
SERIALNO : ***  
BATTDATE : 2010-04-27
NOMINV   : 230 Volts
NOMBATTV : 12.0 Volts
FIRMWARE : 871.O2 .I USB FW:O2
END APC  : 2021-06-29 10:04:08 +0200  

trying it with sensor config

- platform: apcupsd
  resources:
    - end apc

is not working, because the integration only accepts

- platform: apcupsd
  resources:
    - endapc

What is version of Home Assistant Core has the issue?

2021.6.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

apcupsd

Link to integration documentation on our website

https://www.home-assistant.io/integrations/apcupsd/

Example YAML snippet

- platform: apcupsd
  resources:
    - endapc

Anything in the logs that might be useful for us?

2021-06-29 09:59:24 WARNING (SyncWorker_6) [homeassistant.components.apcupsd.sensor] Sensor type: endapc does not appear in the APCUPSd status output

Additional information

No response

RyanMathewson commented 3 years ago

Is that field of any value within Home Assistant? It doesn't seem worth fixing to get that field working.

nicx commented 3 years ago

@RyanMathewson In my opinion this field is worth it, because with that field working you could use it in automations to do things like "is my connection to the apc still working? if not notify me or do a reboot".

end apc: Date and time of status information was written

RyanMathewson commented 3 years ago

@nicx I was going to set up the same kind of alert automation but using the "DATE" field. DATE - The date and time that the information was last obtained from the UPS. This seems like a better indication of valid communication with the UPS than the "END APC" field which is just be the local timestamp of when Home Assistant last queried the status.

I might try to fix #35230 and could try to resolve this issue at the same time but I'm still struggling to see the value.

nicx commented 3 years ago

@RyanEwen I just had a good at the source code... and as far as I see this bug could be fixed with only one "blank" added to line 46 in the sensor.py:

OLD: "endapc": ["Date and Time", "", "mdi:calendar-clock", None], NEW: "end apc": ["Date and Time", "", "mdi:calendar-clock", None],

So if you could fix this it would be great. Even if you are struggling with the value, its just a bug that should be solved. Otherwise this parameter should be removed completely. But buggy software is never a solution for me :)

RyanEwen commented 3 years ago

I think you tagged me by mistake instead of RyanMathewson :)

nicx commented 3 years ago

huh, you are right @RyanEwen, sorry for that :)

@RyanMathewson this was meant for you. :)

mib1185 commented 3 years ago

Would suggest to switch to the NUT integration, since the add-on APC UPS Daemon is not maintained anymore. There is also a proper Supervisor Add-On available https://github.com/hassio-addons/addon-nut.

nicx commented 3 years ago

@mib1185 I dont have a NUT server running, so the NUT integration is not an option.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

nicx commented 2 years ago

still an issue

yuxincs commented 2 years ago

I think this is fixed by https://github.com/home-assistant/core/pull/59200 and can be closed 😃