koochyrat / comfort2

Cytech Comfort 2 Alarm MQTT Bridge (Home Assistant/OpenHAB compatible)
Apache License 2.0
6 stars 4 forks source link

Away Mode not reported in HA #2

Open auredor opened 5 years ago

auredor commented 5 years ago

Hello,

While using Comfort with Away mode, Day mode and Security Off, there are no issue with what is reported to HA components : Alarm Control Panel, Alarm message and Alarm Counter.

However, if I use the Night mode, the Alarm Control Panel show Pending while counting down before enabling the alarm. Bur once the Comfort system goes to Night mode, the Alarm Control Panel keep showing "Pending".

I've seen that there is no on_message callback to process Night mode message in Comfort2.py. I've tried to add the following code but it doesn't help :

if msg.topic == ALARMCOMMANDTOPIC: if self.connected: if msgstr == "ARM_HOME": self.comfortsock.sendall(("\x03m!03"+self.comfort_pincode+"\r").encode()) #arm to 03 day mode elif msgstr == "ARM_NIGHT": self.comfortsock.sendall(("\x03m!02"+self.comfort_pincode+"\r").encode()) #arm to 02 night mode
elif msgstr == "ARM_AWAY": self.comfortsock.sendall(("\x03m!01"+self.comfort_pincode+"\r").encode()) #arm to 01 away mode elif msgstr == "DISARM": self.comfortsock.sendall(("\x03m!00"+self.comfort_pincode+"\r").encode()) #arm to 00 disarm mode

Also, I've seen that we can use a code to disarm the alarm from HA. But, in this case, e must also use a code to arm it from HA. This is not the case with Comfort Hardware. I guess, this is not possible to change it as it's related to the Alarm Control Panel component behavior, right ?

Thank you.

koochyrat commented 5 years ago

The Alarm control panel UI in HA does not support arming Night mode, so that is why I have not included the mapping. Although if you manually arm Comfort to Night mode through other means, it does show up.

As a workaround, if you add that ARM_NIGHT line as above, you can add a corresponding MQTT switch in HA to make it arm to Night mode.

auredor commented 5 years ago

@koochyrat Have you already suggested HA team to add this mode ?

Thanks.

koochyrat commented 5 years ago

@auredor No, you can go ahead and suggest it and see if anyone will take it up. I will add the ARM_NIGHT line and close this issue in the meantime.

schford commented 5 years ago

IF you use this card under lovelace - https://community.home-assistant.io/t/lovelace-alarm-card/59831

It Supports arming night mode.

Ill have a play tomorrow.

Stuart

auredor commented 5 years ago

Thank you @schford for the link. Need some more time to integrate lovelace UI. In the meantime, I'm still waiting to get the code update with "ARM_NIGHT" from @koochyrat. I've tried as above but it looks like I'm missing something because when I get push notification from alarm change, I'm still getting "pending" as message although I've also added 'armed_night' to the notification list template in HA :

- alias: Alarm State Notification
  trigger:
    platform: state
    entity_id: alarm_control_panel.comfort_alarm
  action:
    service: notify.ios_XXXXXXX
    data_template:
      title: '{{ trigger.to_state.attributes.friendly_name }}'
      message: "{% if is_state('alarm_control_panel.comfort_alarm', 'armed_home')\
        \ %}\n    Armed Home\n{% elif is_state('alarm_control_panel.comfort_alarm',\
        \ 'armed_away') %}\n    Armed Away\n{% elif is_state('alarm_control_panel.comfort_alarm',\
        \ 'armed_night') %}\n    Armed Night\n{% elif is_state('alarm_control_panel.comfort_alarm',\
        \ 'disarmed') %}\n    Disarmed\n{% elif is_state('alarm_control_panel.comfort_alarm',\
        \ 'pending') %}\n    Pending\n{% elif is_state('alarm_control_panel.comfort_alarm',\
        \ 'triggered') %}\n    Triggered\n{% else %}\n    {{ trigger.to_state.state\
        \ }}\n{% endif %}\n"

So, I'm not sure that the CALL_BACK function with "ARM_NIGHT" is doing is job properly... as I son't get the right notification.

Thanks

auredor commented 5 years ago

OK. So, finally I had to change the mqtt.py file from the alarm_control_panel component in order to manage the arm_night mode on the front-end. Now, I got the proper info in the front-en while using Night mode from the comfort system and I got also the right notification.

However, it's not possible to arm the system in night mode from the front-end because the ARM NIGHT button doesn't exist. I've looked at the mode-info-alarm_control_panel.js from home-assistant-polymer github and it should be easy to change it to manage this additional button. But I don't have setup the polymer development environment so I can't not do it and test it.

Using the modified mqtt.py, I believe it should work with the lovelace UI. I have to give it a try.

koochyrat commented 5 years ago

I've added the ARM_NIGHT lines. Thanks for sharing your progress!