WTH are apcupsd and NUT polling integrations

Both the apcupsd and the Network UPS Tools/NUT integrations use polling, so it could be 30-60 seconds before an automation triggers on power failure or voltage drop, and its very possible that it will miss short outages all together.

I haven’t dug into the code or inner workings of apcupsd or NUT, but surely there’s a way to get triggers from at least one of them directly instead of having to poll?

apcupsd itself is based on polling. The default polling time is 60 seconds, and it drops to 1 second when the UPS is on battery. You can customize that in the APCUPSD config though with the POLLTIME option (I think I have it set to 10 seconds).

I don’t use the APCUPSD integration, but it would be nice if it had a configurable scan interval (maybe this works?) Either way, this might be an option for you (it’s what I use): https://github.com/Villhellm/apc2mqtt

Something I had to do for the apc2mqtt. I run the mosquitto broker addon, so its running in a container, so this is a container to container communication. Then you need to adjust the composer file adding in network_mode, specifying the MQTT_HOST ip.

version: '3'
services:
  apc2mqtt:
    container_name: apc2mqtt
    image: apc2mqtt:latest
    network_mode: host
    environment:
    - HOMEASSISTANT_PREFIX=homeassistant
    - MQTT_USER=user
    - MQTT_PASSWORD=password
    - MQTT_HOST=ip_of_mqtt_broker_in_hassio_network
    - MQTT_PORT=1883
    - MQTT_TOPIC_PREFIX=apc
    - MQTT_TIMEOUT=10
    - MQTT_QOS=1
    - INTERVAL=10
    - UPS_ALIAS=ups
    - APCUPSD_HOST=127.0.0.1
    - DEBUG=1
    restart: unless-stopped