gwww / elkm1

ElkM1 Python package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Voltage is not initialized on startup

jimboca opened this issue · comments

Describe the bug
After sync_complete, the zone.volatage is always zero

To Reproduce
Steps to reproduce the behavior:

  1. In bin/simple change sync_complete to:
    def sync_complete():
        print("Sync of panel is complete!!!")
        an = 0
        print(f"area {an}={elk.areas[an]}")
        for zn in range(Max.ZONES.value-1):
            if elk.zones[zn].area == an and elk.zones[zn].definition > 0:
                print(f" zone {elk.zones[zn]}")

Expected behavior
Initialize with current voltage

Screenshots

Connecting to ElkM1 at elk://somehost:port
Connected to ElkM1
Connected!!!
Sync of panel is complete!!!
area 0 'Home' armed_status:0 arm_up_state:1 alarm_state:0 alarm_memory:None is_exit:False timer1:0 timer2:0 last_log:None
 zone 0 'Garage Door Left' type:BURGLAR_ENTRY_EXIT_2 status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 1 'Guest Window 1' type:BURGLAR_PERIMETER_INSTANT status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 2 'Guest Window 2' type:BURGLAR_PERIMETER_INSTANT status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 3 'Master Window 1' type:BURGLAR_PERIMETER_INSTANT status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 4 'Master Window 2' type:BURGLAR_PERIMETER_INSTANT status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 5 'Master Bath Win' type:BURGLAR_PERIMETER_INSTANT status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 6 'Side Gate Left' type:NON_ALARM status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 7 'Side Gate Right' type:NON_ALARM status:NORMAL/EOL area:0 trig:False v:0 temp:-60
 zone 8 'Family Door' type:BURGLAR_PERIMETER_INSTANT status:NORMAL/EOL area:0 trig:False v:0 temp:-60
...

Versions (please complete the following information):

  • ElkM1 version: [0.8.8]
  • Home Assistant version: [NA]

Additional context
Is there another way to force update to proper voltage?

Well, this one was intentional. Because zone voltage is something that fluctuates rather rapidly I didn't see the use of syncing it. And, it will not automatically update when it changes. Happy to be convinced differently.

One thing that could be done which is a feature request is to add a helper to retrieve the zone voltage. It can already be retrieved just that the couple of lines of code of the helper simplifies retrieval ever so slightly.

I've had requests from users to show zone voltage, so I was looking at adding it.
I am seeing the callback come thru with voltage changes, but not all changes. I don't have elkm1_lib debugging on, but can enable that if you want to see more

2021-02-03 22:40:04,083 ELK-13600  polyinterface      DEBUG    Zone:callback: Guest Window 1: changeset={'voltage': 7.1}

A simple helper would be great if you feel it should not be synced on startup or change. But it may not be valuable to users if it doesn't update when changed automatically.

I added get_voltage helper on the Zone. It is in version 0.8.11 that was just published.

With respect to the zone callback with voltage that you reference, the library has never requested voltage before so that would mean something is calling zv_encode and send outside of the library (which is all the helper does, it just puts a nice wrapper on it).

Just in case you care, all the helpers are consistently labelled with (Helper) in their docs. I use it to discover all the helpers that exist. See https://github.com/gwww/elkm1/blob/main/bin/cmdr.py#L76-L91

Thanks for adding get_voltage.

I've no idea how all the callback is coming with voltage, I'm not calling zv_encode, but it seems to happen some time after a periodic panel resync is run?

Thanks for the get_helper info, I'll check it out.

I'm curious to know the answer to this. I don't see voltage come through unless I ask for it.

Going to close this. Can reopen if there's something you think the library can offer here.