Closed h4nc closed 5 years ago
I did not know that this was already implemented.
Solved it with this:
- platform: rest
name: gigaset_health
resource: http://MYIP:3000/api/v2/me/health
value_template: '{{ value_json.system_health }}'
json_attributes:
- "status_msg_id"
- "updates_available"
and I use this for the online/offline state:
binarysensor.yaml:
- platform: rest
name: gigaset_availability
scan_interval: 10
resource: http://MYIP:3000/api/v1/me/basestations
value_template: "{{ value_json[0].status == 'online' }}"
in automations.yaml
- alias: Gigaset - alarmtrigger
initial_state: 'on'
trigger:
platform: template
value_template: "{% if is_state('sensor.gigaset_health', 'red') %}true{% endif %}"
condition:
condition: template
value_template: "{{ states.sensor.gigaset_health.attributes.status_msg_id == 'system_intrusion' }}"
action:
...
- alias: Gigaset - offline
initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.gigaset_availability
to: 'off'
for: '00:01:00'
action:
...
Now with that alarmtrigger, we can trigger other lights to (not only hue). Everything is possible with that, e.g a mqtt based flashing lightm an outdoor siren ... Other ideas are welcome!
I rethought this.
I still think it would be better the push the alarm via mqtt as this would be some seconds faster. The other way with the restful sensor will be slower because it looks for a new state every x seconds (10 in my case). So worst case it would take 10 seconds longer than mqtt.
Hello, you've been busy during these vacations !
Sure it would be a good idea to catch an gigaset alarm event and transform it to a MQTT event. I can add this but I will need some sample: can you generate an alarm event and send it to me (you can check passed events in the
Sure I can, this are the events that appear after an alarm is triggered:
{
"events": [
{
"id": "XXX",
"o": {
"cre_uid": "XXX",
"friendly_name": "Haus",
"frontendTags": {
},
"modeAfter": "home",
"modeBefore": "away",
"status": "success",
"userId": "XXX"
},
"source_id": "XXX",
"source_type": "bs01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "isl01.bs01.intrusion_mode_loaded"
},
{
"id": "XXX",
"o": {
"basestationFriendlyName": "Haus",
"basestationId": "XXX",
"basestationType": "bs01"
},
"source_id": "app-mids-devices-management@XXXXX.reef",
"source_type": "iml01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "ack_intrusion"
},
{
"id": "XXX",
"o": {
"basestationFriendlyName": "Haus"
},
"source_id": "app-services-intrusion-detector@XXXXX.reef",
"source_type": "isl01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "ack_intrusion"
},
{
"id": "XXX",
"o": {
"modeAfter": "home",
"modeBefore": "away"
},
"source_id": "app-services-intrusion-detector@XXXXX.reef",
"source_type": "isl01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "isl01.configuration_changed.user.intrusion_mode"
},
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Haus",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "on"
},
{
"id": "XXX",
"o": {
"friendly_name": "motion outdoor",
"frontendTags": {
},
"id": "XXX",
"type": "ps02"
},
"parents": [
"XXX"
],
"source_id": "XXX",
"source_name": "Haus",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "intrusion"
}
],
"home_state": "ok"
}
I think you will need this:
"source_type": "isl01"
or "source_type": "iml01"
with "type": "ack_intrusion"
By the way: I also came up with the idea to ping the raspi running your component every few minutes, just to be sure it is still online. It happened once that the raspi hung up and I had to pull the plug and restart it this way.
I'm not sure we should track the "ack_intrusion" event: it might correspond to the acknowledgment of the intrusion you did (or the application did) in the gigaset application.
Events are listed in reverse orders (you can tell by the timestamp field, "ts"): most recent being the first. What is see from your list of events:
I'll be tempted to track the siren event (but I don't know what happens if the siren is offline), but I can be wrong. Can you have a look at the events before and after acknowledging the intrusion ?
I will fire another alarm and have look at the events before.
Currently it works like this, couldn't we use this data too?
- platform: rest
name: gigaset_health
scan_interval: 10
resource: http://myip:3000/api/v2/me/health
value_template: '{{ value_json.system_health }}'
json_attributes:
- "status_msg_id"
automation.yaml
- alias: Gigaset - Alarmtrigger on
initial_state: 'on'
trigger:
platform: state
entity_id: sensor.gigaset_health
to: 'red'
condition:
condition: template
value_template: "{{ states.sensor.gigaset_health.attributes.status_msg_id == 'system_intrusion' }}"
action:
...
So I used the values from the "health" section. If the thesystem_health
and status_msg_id
(which only appears when system health
goes to red
.
EDIT: Seems like it's not enough to unplug the siren, I'l have to wait till it is offline and that takes a while.
I fired two alarm one with the siren plugged in and one without.
those are all the events for siren plugged in:
{
"events": [
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "off"
},
{
"id": "XXX",
"o": {
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"type": "is01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "sirenoff"
},
{
"id": "XXX",
"o": {
"basestationFriendlyName": "Zuhause",
"basestationId": "XXX",
"basestationType": "bs01"
},
"source_id": "app-mids-devices-management@XXX.reef",
"source_type": "iml01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "ack_intrusion"
},
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "on"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"parents": [
"XXX"
],
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "intrusion"
},
{
"id": "XXX",
"o": {
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"type": "is01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "sirenon"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "close"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "open"
},
{
"id": "XXX",
"o": {
"cre_uid": "XXX",
"friendly_name": "Zuhause",
"frontendTags": {
},
"modeAfter": "away",
"modeBefore": "home",
"status": "success",
"userId": "XXX"
},
"source_id": "XXX",
"source_type": "bs01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "isl01.bs01.intrusion_mode_loaded"
},
{
"id": "XXX",
"o": {
"modeAfter": "away",
"modeBefore": "home"
},
"source_id": "app-services-intrusion-detector@XXX.reef",
"source_type": "isl01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "isl01.configuration_changed.user.intrusion_mode"
}
],
"home_state": "ok"
}
and without siren:
{
"events": [
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "off"
},
{
"id": "XXX",
"o": {
"basestationFriendlyName": "Zuhause",
"basestationId": "XXX",
"basestationType": "bs01"
},
"source_id": "app-mids-devices-management@dkrh1.reef",
"source_type": "iml01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "ack_intrusion"
},
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "on"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"parents": [
"XXX"
],
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "intrusion"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "close"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "open"
},
{
"id": "XXX",
"o": {
"cre_uid": "XXX",
"friendly_name": "Zuhause",
"frontendTags": {
},
"modeAfter": "away",
"modeBefore": "home",
"status": "success",
"userId": "XXX"
},
"source_id": "XXX",
"source_type": "bs01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "isl01.bs01.intrusion_mode_loaded"
},
{
"id": "XXX",
"o": {
"modeAfter": "away",
"modeBefore": "home"
},
"source_id": "app-services-intrusion-detector@XXX.reef",
"source_type": "isl01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "isl01.configuration_changed.user.intrusion_mode"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "close"
},
{
"id": "XXX",
"o": {
"friendly_name": "Wohnzimmer",
"frontendTags": {
},
"id": "XXX",
"type": "ws02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "open"
}
],
"home_state": "ok"
}
Ok so this is a event log with an offline siren:
{
"events": [
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "off"
},
{
"id": "XXX",
"o": {
"basestationFriendlyName": "Zuhause",
"basestationId": "XXX",
"basestationType": "bs01"
},
"source_id": "app-mids-devices-management@XXX.reef",
"source_type": "iml01",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "ack_intrusion"
},
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "on"
},
{
"id": "XXX",
"o": {
"friendly_name": "Au?enbereich",
"frontendTags": {
},
"id": "XXX",
"type": "ps02"
},
"parents": [
"XXX"
],
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "intrusion"
},
{
"id": "XXX",
"o": {
"friendly_name": "Außenbereich",
"frontendTags": {
},
"id": "XXX",
"type": "ps02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "movement"
},
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "on"
},
{
"id": "XXX",
"o": {
"friendly_name": "Au?enbereich",
"frontendTags": {
},
"id": "XXX",
"type": "ps02"
},
"parents": [
"XXX"
],
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "intrusion"
},
{
"id": "XXX",
"o": {
"friendly_name": "Außenbereich",
"frontendTags": {
},
"id": "XXX",
"type": "ps02"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "movement"
},
{
"id": "XXX",
"o": {
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"type": "is01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "endnode_offline_notification"
},
{
"id": "XXX",
"o": {
"consumed": "0",
"delay": "0",
"friendly_name": "Sirene",
"frontendTags": {
},
"id": "XXX",
"reason": "cmd",
"type": "sp01"
},
"source_id": "XXX",
"source_name": "Zuhause",
"source_type": "basestation",
"state": "ok",
"state_pre": "ok",
"ts": "XXX",
"type": "off"
}
],
"home_state": "ok"
}
Cool ! So we can rely on an "Siren" event (ev.o.type="sp01"), even if the Siren is offline. I will implement that.
Great, thanks. Let me know when it's ready for testing ;-)
I've just published an new release.
It's tracking the "fire Siren command" event and generates a MQTT one in the form:
- topic: "gigaset/<mySirenName>"
- value: "true"
Thanks I will try that.
Bye the way I found a spelling mistake:
intrusion stettings: selected mode of the alarm system
It's tracking the "fire Siren command" event and generates a MQTT one in the form:
Just to make sure.
This will go to true when the alarm is fired and goes back to false when is goes back to normal mode right? If this only fired at the alarm start, there is nothing that stops blinking lights when the alarm is stopped.
It thats to complicated, I will use the restful sensor (as I do it currently) to stop the automation like this
trigger:
- platform: state
entity_id: sensor.gigaset_health
#from: 'red'
to: 'green'
- platform: state
entity_id: sensor.gigaset_health
#from: 'red'
to: 'orange'
Oops you're right: there is also an "siren off command", I'm mapping this one also so that you can react when the intrusion is acknowledged. Have a look on the latest version.
I triggered an alarm and my new binary sensor tracking the mqtt event didn't go to true.
The topic I listen to is gigaset/Sirene
.
I remember there was a way to see to which topics it publishes in the terminal (where gigaset api runs), but I don't know exactly where I can see that.
EDIT: Also I think it would be nice to add this to the force refresh page too.
EDIT2: I fired another alarm and also listened to this topic with another tool. Nothing appears in this topic. Something doesn't work right or wrong topic.
If you started it as a service, you can use journalctl -fu gigaset-server@pi
(it's in the example directory)
It seems like the mqtt part of the project is broken, because other automations are not triggered any more.
For example I use the motion sensor to turn on a light. Looking into this I saw that no motion was sent to homeassistant since the update. The motion events appear in the event list but no mqtt.
EDIT: journalctl -fu gigaset-server@pi only gives me the event list but the mqtt topics are not listed.
:'(
I did some change to be able to modify the topic names... and I forgot to put the gigaset/
prefix. It should be back to normal now.
Nevermind, this is part of the whole game ;-)
I'll try and come back
EDIT: MQTT works again. I still have to try the alarmtrigger. Looking forward to closing this issue.
Ok so I triggered the alarm and binary sensor watching this topic turned true instantly. But there was a big delay turning the binary sensor back to false (and I use this to turn the alarmed lights off again).
This took some minutes to go back to false, but I only had the alarm for about 20 seconds. My restful sensor immediately turned "green" again.
Don't know why this delay happened? What do you think about it? Maybe we should use something else for triggering (like the green/red state toghetet with status_msg_id as I mention before).
Sorry, I did not have time to work on your delay problem, I suspect it's related to the Gigaset backend itself. I'd really prefer not mixing event management with pulling sensor state in the code. If you can do it in home-assistant... well it's better.
What should I do with this issue ? Remove the "going back to green" functionality ? Leave it as it is ? You tell me.
Currently I use both option
I use the mqtt topic to turn on an automation (turn lights to blinking red, ...).
To turn off the automation I use the restful sensor (to: green
and to: orange
state; not sure if I could replace both by 'from: red') because this worked reliable for me (as I said there was a big delay sometimes for the topic to go back to 'off' for some reason).
What should I do with this issue ? Remove the "going back to green" functionality ? Leave it as it is ? You tell me.
The best way would be to make mqtt reliable. But I can also live with using both mqtt and rest sensor. So you can leave it like it is.
ok !
Hi again,
I had a new idea lately. It would be great to trigger automations in home assistant, when an alarm fires in gigaset.
Do you think you can add this? I think it would be nice to publish this information in its on topic.
There is a new zigbee based siren which would be nice to add, because it is outdoor capable.