Tertiush / ParadoxIP150v2

Python-based IP150 'middle-ware' that uses the IP module's software port for monitoring and control of the alarm via an MQTT Broker.
Eclipse Public License 1.0
73 stars 35 forks source link

Possible enhancement - event to topic translation #19

Open psyciknz opened 7 years ago

psyciknz commented 7 years ago

So you'll see in some of my code I added specific events to topics. Eg zone status to their own topics and a arm/disarm state to a topic.

I've got occasion now, to add a button press as a topic so I can alert on it (son pressed a button which opened the garage door this morning by accident, so I want to get a notification of this event).

I started thinking of ways to do it. It seems you've already got a lot of event defined in the Map files. So I'm thinking of some sort of event to topic translation in the config.

Something like

[events]
<eventcode>:events/<topicname>
eg:
11:events/disarm
12:events/arm

which replicates this code:

elif ord(message[7]) == 2 and ord(message[8]) == 11:   #Disarm
    logging.info("Publishing event \"%s\" =  %s" % (Topic_Publish_ArmState, "disarm"))
    client.publish(Topic_Publish_ArmState ,"OFF", qos=0, retain=False)
elif ord(message[7]) == 2 and ord(message[8]) == 12:   #arm
    logging.info("Publishing event \"%s\" =  %s" % (Topic_Publish_ZoneState, "arm"))
    client.publish(Topic_Publish_ArmState ,"ON", qos=0, retain=False)

Or the other way we could do it is actually post evetn event to a numeric topic rather than do a text conversion. It means that the events can be assigned to switches or contact items.

Thoughts?

Tertiush commented 7 years ago

I think keeping with numeric topics published to the broker is more generic. An end user can then use a higher order system (e.g OH or HA) to translate and action on it. It is also more independent of other languages that Paradox supports.