Comfort Home Automation/ Security System Forums Home

 Moderated by: slychiu  
AuthorPost
koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

Hi all,

I am sharing my Comfort integration with Home Assistant. This is a standalone Comfort to MQTT bridge for Cytech's Comfort II Ultra Alarm system with UCM/ETH03 module primarily intended to integrate with Home Assistant (or OpenHAB or other MQTT compatible systems). It can run on a Raspberry Pi and other systems with Python 3 support.

With Home Assistant, you can further extend the Comfort system with more complex logic, inputs, outputs and actions. Using virtual inputs, you can define additional zones in Comfort triggered by any sensor available in your Home Assistant setup. Or vice-versa, having Comfort trigger any action in your Home Assistant setup.


Instructions and source code available at:
https://github.com/koochyrat/comfort2

Attached is my HADashboard setup for Home Assistant

Attachment: hadashboard.png (Downloaded 263 times)

Last edited on Saturday Apr 14th, 2018 08:45 pm by koochy_rat

slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5046
Status: 
Offline

  back to top

Very nice, Koochy_rat!
I hope you dont mind us sharing your news

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

No problem, please share away. It's totally free for anyone to use, modify or distribute :D

Sota
UCM Pi Users
 

Joined: Friday May 3rd, 2013
Location: Galway, Ireland
Posts: 32
Status: 
Offline

  back to top

This is something I've been thinking about but I'm not familiar with Home Assistant, do you have any guidance on using this with OpenHAB / Mosquitto?

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

Sorry, I am not familiar with OpenHAB, but it should just be about defining the appropriate topics for MQTT sensors and switches. The should be some guides out there on how to do this. Test with just one sensor, say "comfort2/input1" then activate that input by opening/closing doors or windows in the corresponding zone and you should see some message in the comfort2.py console as well as your mosquitto log and hopefully in OpenHAB. Comfort alarm does not need to be armed for this.

mikeinnc
Member
 

Joined: Wednesday Mar 18th, 2015
Location: Perth, Australia
Posts: 69
Status: 
Offline

  back to top

So, I have Home Assistant (HA) successfully running on a RaspberryPi with my MQTT broker, Mosquitto, running on another, separate, Pi on my home network. HA is using MQTT and it works perfectly for a number of Tasmota flashed switches. If I want to connect my Comfort alarm system to HA, is it essential I install the paho-mqtt client, and presumably on the Pi running HA? And - can Comfort be shown in HA automatically, or must I use the command once HA is running? Thanks so much for this - it looks like it will be fantastic! :)

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

Yes, the comfort2.py script requires paho-mqtt library to be installed. It is not a broker so it won't interfere with your Mosquitto and HA. You can run it on any Pi in your network. Comfort will not show in HA automatically, you will need to manually setup HA accordingly with MQTT alarm, sensors, and switches. Check my github link above for details. Since you are using Mosquitto as your broker, set comfort2.py to connect to it. It doesn't matter who starts up first as it will constantly reattempt connection.

mikeinnc
Member
 

Joined: Wednesday Mar 18th, 2015
Location: Perth, Australia
Posts: 69
Status: 
Offline

  back to top

Thanks so much to koochy_rat for all his help and assistance with this fabulous extension to Comfort! Home Assistant (HA) is an open-source program that will happily run on a Raspberry Pi and can control and monitor numerous 'smarthome' devices. Being able to integrate Comfort with HA is a huge plus as it brings everything together under one UI. After a couple of minor issues, which koochy_rat soon fixed, I have this working. One issue that may be of use is that if you follow the instructions supplied, if - or when - your terminal session times-out, the program will stop running and all the Comfort entities will be unavailable. I found that using the command 'exec python3 comfort2.py &> /dev/null &' ensures it runs in the background and will NOT stop when you close your Pi terminal session. If you then need to stop the process, use top -u pi (assuming you are running it as the pi user) to see what PID is associated with the python3 process and then kill xxxx where xxxx is that PID. Great work - well worth looking at!:)

phil1155
Member
 

Joined: Friday Nov 9th, 2012
Location:  
Posts: 48
Status: 
Offline

  back to top

Hi Koochy_rat,
I was looking for a way to get Comfort to talk to my Home Automation system and you have created one. Thanks for that.
I implemented Comfort2.py on a debian VM machine ( esxi Vmware) which is also running an open source HA system named Jeedom. I just took out the line calling Home Assistant.
My jeedom app detected the comfort2 "equipment " and started to record the first status messages send by comfort. So was happy to see the disarmed sattus to appear when I did disarmed the alarm.

Now, is it possible to get my Jeedom app to send commands to Comfort through Mosquitto? Any examples of commands would be helpful. Thank you again.

Attachment: object created in jeedom.jpg (Downloaded 208 times)

Last edited on Monday May 28th, 2018 04:16 pm by phil1155

phil1155
Member
 

Joined: Friday Nov 9th, 2012
Location:  
Posts: 48
Status: 
Offline

  back to top

Hi Koochy_rat,
I was looking for a way to get Comfort to talk to my Home Automation system and you have created one. Thanks for that.
I implemented Comfort2.py on a debian VM machine ( esxi Vmware) which is also running an open source HA system named Jeedom. I just took out the line calling Home Assistant.
My jeedom app detected the comfort2 "equipment " and started to record the first status messages send by comfort. So was happy to see the disarmed sattus to appear when I did disarmed the alarm.

Now, is it possible to get my Jeedom app to send commands to Comfort through Mosquitto? Any examples of commands would be helpful. Thank you again.

Attachment: debian terminal.jpg (Downloaded 208 times)

Last edited on Monday May 28th, 2018 04:17 pm by phil1155

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

I'm not familiar with Jeedom, but a quick search shows that there are quite a few MQTT plugins for it. To send commands, you mainly just need to publish the 'comfort2/alarm/set' topic to ARM_HOME, ARM_AWAY or DISARM

phil1155
Member
 

Joined: Friday Nov 9th, 2012
Location:  
Posts: 48
Status: 
Offline

  back to top

Thanks for the answer , I can see coming traffic form comfort in my debian terminal window, can see that it records a new entry in the list of commands, but did not finf the way /syntax to get a command send from my jeedom app to comfort. IN the sample I published, is the topic syntax ok? And the "Valeur" ( Payload), just DISARM? When testing this command I dont see anything on my debian terminal window.

phil1155
Member
 

Joined: Friday Nov 9th, 2012
Location:  
Posts: 48
Status: 
Offline

  back to top

Replying to myself.
I was missing to publish as a message. Works now. Many thanks.
Is there a list of the Value(Payload) possibilities to access all commands of Comfort?I am trying to get the gsm message to be forwarded to my HA app through MQTT.

Last edited on Wednesday May 30th, 2018 10:52 am by phil1155

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

If you'd like more control over Comfort, you can use Comfigurator to program a custom Response that allows you to use Comfort internal commands. Then use MQTT to trigger that Response. However I'm not sure if getting the gsm message is possible even with that.

phil1155
Member
 

Joined: Friday Nov 9th, 2012
Location:  
Posts: 48
Status: 
Offline

  back to top

Was able to record a Control group command in the Comfort SMS table that did actionnate a flag, captured by MQTT and by my jeedom app.
Means I should now send through comfort SMS to actioonate any other equipment that is not connected to comfort.

steefdebruijn
Member
 

Joined: Sunday Jul 29th, 2012
Location: Netherlands
Posts: 28
Status: 
Offline

  back to top

About starting the thing on a raspberry pi: that system (I use dietpi but others probably the same) uses systemd. So to use it unattended and autostart on boot, create a systemd service file (example below) and enable and start it.

The file (place in /etc/systemd/system/comfort2.service):

[Unit]
Description=Cytech Comfort to MQTT bridge
After=local-fs.target network.target

[Service]
Type=simple
ExecStart=/usr/bin/python3 /root/comfort2.py

[Install]
WantedBy=multi-user.target


Enable and start it:
systemctl daemon-reload
systemctl enable comfort2
systemctl start comfort2


Steef

steefdebruijn
Member
 

Joined: Sunday Jul 29th, 2012
Location: Netherlands
Posts: 28
Status: 
Offline

  back to top

BTW anyone noticed that setting an OUTPUT through MQTT offsets by one (setting comfort2/output10/set to 1 sets output 11 not output 10)? Seems not to happen at other inputs.

Other thing: has anyone succesfully used virtual inputs (so set an input through MQTT to comfort and was able to see this reflected in comfigurator status?

I use this script adapted to USB input instead of ETH with openhab on the other side of MQTT.

wexfordman
UCM Pi Users
 

Joined: Monday Jan 1st, 2007
Location: Cork, Ireland
Posts: 527
Status: 
Offline

  back to top

mikeinnc wrote: Thanks so much to koochy_rat for all his help and assistance with this fabulous extension to Comfort! Home Assistant (HA) is an open-source program that will happily run on a Raspberry Pi and can control and monitor numerous 'smarthome' devices. Being able to integrate Comfort with HA is a huge plus as it brings everything together under one UI. After a couple of minor issues, which koochy_rat soon fixed, I have this working. One issue that may be of use is that if you follow the instructions supplied, if - or when - your terminal session times-out, the program will stop running and all the Comfort entities will be unavailable. I found that using the command 'exec python3 comfort2.py &> /dev/null &' ensures it runs in the background and will NOT stop when you close your Pi terminal session. If you then need to stop the process, use top -u pi (assuming you are running it as the pi user) to see what PID is associated with the python3 process and then kill xxxx where xxxx is that PID. Great work - well worth looking at!:)

Hi,
I am trying to see if I can get this working with openhab2.
So far I have installed mosquitto broker, and installed paho-mqtt
I am confused now as the next step is to edit the comfort2.py file but I cannot find this, where should it be located ?

schford
UCM Pi Users
 

Joined: Wednesday Feb 25th, 2009
Location:  
Posts: 248
Status: 
Offline

  back to top

You need to grab it from here - https://github.com/koochyrat/comfort2/blob/master/comfort2.py

I just copied and pasted it into a notepad ++ window and then saved that file to where I could run it.

Last edited on Thursday Jun 21st, 2018 04:11 pm by schford

wexfordman
UCM Pi Users
 

Joined: Monday Jan 1st, 2007
Location: Cork, Ireland
Posts: 527
Status: 
Offline

  back to top

Thanks, so I have an matt broker setup, I have comfort talking to it, and I have openhab talking to the broker. Now just need to figure out how to get them to bejave

steefdebruijn
Member
 

Joined: Sunday Jul 29th, 2012
Location: Netherlands
Posts: 28
Status: 
Offline

  back to top

Create a file cytech.items in folder items with (for example) following input:

Contact MyDoor <frontdoor> {mqtt="<[mqtt:comfort2/input1:state:MAP(openclosed.map)]"}
Contact MyWindow <window> {mqtt="<[mqtt:comfort2/input2:state:MAP(openclosed.map)]"}
Contact MyMoveSensor <selfmotion> {mqtt="<[mqtt:comfort2/input3:state:MAP(openclosed.map)]"}
Contact MyCytechController <network> {mqtt="<[mqtt:comfort2/alarm/online:state:MAP(openclosed.map)]"}
String MyAlarmState <alarm> {mqtt="<[mqtt:comfort2/alarm:state:default]"}


In the above situation I have

    * Frontdoor at input 1
    * A window at input 2
    * Motion sensor at input 3
    * Broker has name mqtt

File `open closed.map` in folder `transform`:
key=value
1=OPEN
0=CLOSED
OPEN=1
CLOSED=0

wexfordman
UCM Pi Users
 

Joined: Monday Jan 1st, 2007
Location: Cork, Ireland
Posts: 527
Status: 
Offline

  back to top

steefdebruijn wrote: Create a file cytech.items in folder items with (for example) following input:

Contact MyDoor <frontdoor> {mqtt="<[mqtt:comfort2/input1:state:MAP(openclosed.map)]"}
Contact MyWindow <window> {mqtt="<[mqtt:comfort2/input2:state:MAP(openclosed.map)]"}
Contact MyMoveSensor <selfmotion> {mqtt="<[mqtt:comfort2/input3:state:MAP(openclosed.map)]"}
Contact MyCytechController <network> {mqtt="<[mqtt:comfort2/alarm/online:state:MAP(openclosed.map)]"}
String MyAlarmState <alarm> {mqtt="<[mqtt:comfort2/alarm:state:default]"}


In the above situation I have

    * Frontdoor at input 1
    * A window at input 2
    * Motion sensor at input 3
    * Broker has name mqtt

File `open closed.map` in folder `transform`:
key=value
1=OPEN
0=CLOSED
OPEN=1
CLOSED=0



Thanks Steef, I think I am almost there :-)
So in my openhab logfile, motion is being detected, but there seems to be an issue with the transformation ?  Below is the error message. Now I suspect it may be to do with my broker name, which even though I set it up, I cant remember what the broker name is/was ?  How do I get this info ?
2018-06-22 16:37:50.610 [WARN] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type MAP
2018-06-22 16:37:50.616 [WARN] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'MyMoveSensor'
[code]Sorted :-)
Had to add the mqtt transformation service, and my mqtt broker name is broker ?

Last edited on Friday Jun 22nd, 2018 04:58 pm by wexfordman

steefdebruijn
Member
 

Joined: Sunday Jul 29th, 2012
Location: Netherlands
Posts: 28
Status: 
Offline

  back to top

You need to install the map transformation from the paper UI. Addons -> Transformations -> MAP transformation

wexfordman
UCM Pi Users
 

Joined: Monday Jan 1st, 2007
Location: Cork, Ireland
Posts: 527
Status: 
Offline

  back to top

steefdebruijn wrote: You need to install the map transformation from the paper UI. Addons -> Transformations -> MAP transformation

All working now thanks, although I havnt managed to get it running 24/7 it drops out every now and again and I need to CLI in to get the comfort. Py running

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

Ok, finally I have gotten around to setting up and trying out the virtual inputs. Firstly, you need to setup a Response to reference the Virtual Input (17 and above only). This is a dummy response merely to let Comfort know the specified input is virtual. Then in Inputs, you should see the Virtual Input column as 'yes'. Then that should be it, you can then set the input through MQTT.


steefdebruijn wrote:
BTW anyone noticed that setting an OUTPUT through MQTT offsets by one (setting comfort2/output10/set to 1 sets output 11 not output 10)? Seems not to happen at other inputs.

Other thing: has anyone succesfully used virtual inputs (so set an input through MQTT to comfort and was able to see this reflected in comfigurator status?

I use this script adapted to USB input instead of ETH with openhab on the other side of MQTT.

Attachment: VirtualInput1.png (Downloaded 114 times)

mikeinnc
Member
 

Joined: Wednesday Mar 18th, 2015
Location: Perth, Australia
Posts: 69
Status: 
Offline

  back to top

After using this very useful program for quite a while now, to interface HA and Comfort, it struck me that with a few modifications, it could also be used to interface my home's CBus lighting system as well.
Comfort allows CBus channels to be mapped to counters (useful for dimmable channels) or flags (useful for relay ie ON/OFF channels), and I had previously done that, mapping my CBus controller channels as required. This has previously allowed me to integrate security with lighting via Comfort responses.
Koochy_Rat's program already interfaces flags to HA, but hadn't included counters. As my CBus system has more dimmable than relay channels, this was an omission I felt needed fixing. There are other methods that can be used to interface CBus to HA - many people report using Clipsl's own CGate application, but I didn't want to introduce yet another interface running on a RPi, if I could avoid it.

So, looking at how KR had programmed the various Comfort components - and despite a very limited knowledge of Python programming! - I was able to add Comfort counters into the 'mix' and can now control CBus lights from HA via MQTT and the Comfort CBus module. And it works very well! There were a few issues with making sure I selected the correct HA configuration for the dimmable channels, but with that in place, the interface works exactly as expected.

OK, I don't have a terribly sophisticated set-up - I don't use Scenes, for example, and have no Scene Controllers - but for a 'simplistic' (although insanely expensive!!) single (CBus) network lighting control system, it works perfectly.

KR has a copy of my modifications, and has promised that he will incorporate them into the mainstream code, so hopefully, although probably a limited number, others will find this useful. Thanks again, KR! :)

Last edited on Sunday Aug 12th, 2018 04:03 am by slychiu

steefdebruijn
Member
 

Joined: Sunday Jul 29th, 2012
Location: Netherlands
Posts: 28
Status: 
Offline

  back to top

koochy_rat wrote:
Firstly, you need to setup a Response to reference the Virtual Input (17 and above only). This is a dummy response merely to let Comfort know the specified input is virtual. Then in Inputs, you should see the Virtual Input column as 'yes'.

I finally got to check this and I discovered I had already tried that. On my comfigurator this does not happen. Response Virtual17 with code Zone17 Off (or On), list of Zones/Inputs keeps Zone17 as virtual=no.

I use Configurator 3.12.5.0 on Windows10. Same behavior with clean file as with my systems file (.cclx)

Steps to reproduce:

    1. Start comfigurator
    2. New file (template Comfort II ULTRA)
    3. Go to Events/Responses
    4. Add response (Name fe Virtual17)
    5. Response code: Virtual Input On/Off, Zone17 Off
    6. Look in Alarms/Zones for virtual input flag on Zone17.

Nope here :-(

Do I miss one little detail?

tia,
Steef

slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5046
Status: 
Offline

  back to top

Check that the Comfort Firmware is upgraded, as well as the latest comfigurator is used
The virtual Input action should be working

steefdebruijn
Member
 

Joined: Sunday Jul 29th, 2012
Location: Netherlands
Posts: 28
Status: 
Offline

  back to top

Hi,

Checking in to confirm that upgrading firmware from 7.140 to 7.142 did it. I now have a virtual input on zone 17 with the scenario two posts back.

Thanks!

Steef

slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5046
Status: 
Offline

  back to top

Thanks for the confirmation.
Virtual Inputs is a very useful feature
Many submodules, eg  IRIO, MSM, Modbus, KNX, Cbus have mapping to Virtual Inputs. This allows other devices to act as Inputs to the security system which can trigger alarms

theshepherdmatt
Member
 

Joined: Monday Jun 17th, 2019
Location:  
Posts: 25
Status: 
Offline

  back to top

Hi mate,
Bit of an old thread, but is it possible to send commands to comfort from openhab? i know that the items file is reading states, but can it set the alarm via published mqtt?
cheersmatt

slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5046
Status: 
Offline

  back to top

You would need UCM/Pi to use MQTT

theshepherdmatt
Member
 

Joined: Monday Jun 17th, 2019
Location:  
Posts: 25
Status: 
Offline

  back to top

Hi Slychui,
I already have koochyrat's python code running on my pi that is receiving mqtt messages from Comfort but I'd like to send commands to comfort from my Pi but I don't know how comfort executes these commands, I think it's under responses but i've hit a wall.
Cheers

slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5046
Status: 
Offline

  back to top

The Comfort serial Protocol is the format of messages sent and received by Comfort which others have used to communicate with Comfort.
You can download from here. http://www.cytech.biz/serial_interface_protocol.html

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

theshepherdmatt wrote:
Hi Slychui,
I already have koochyrat's python code running on my pi that is receiving mqtt messages from Comfort but I'd like to send commands to comfort from my Pi but I don't know how comfort executes these commands, I think it's under responses but i've hit a wall.
Cheers


Yes, using responses is the most flexible way. You can use Comfigurator to program what each response does. Then via MQTT, just set a dummy value to the response to trigger it.

theshepherdmatt
Member
 

Joined: Monday Jun 17th, 2019
Location:  
Posts: 25
Status: 
Offline

  back to top

Hi Hoochy_rat,
Many thanks for the code, I've finally got my head around the Openhab side of MQTT and can now send commands to (via Alexa) Comfort.
Cheers fella

nbexiga
Member
 

Joined: Sunday Oct 17th, 2010
Location: Portugal
Posts: 59
Status: 
Offline

  back to top

HI
i just configure Home Assistant and i can communicate with the comfort.
now i need help with the devices and the configurations that i have currently for my devices.in the main windows , with this yaml file, i only can see ARM AWAY and ARM HOME
I need to configure the way as i have in my cytech configuration , the buttons for AWAY MODE , NIGHT MODE , AND DAY MODE.
Waht changes do i have to make in the yaml file from https://github.com/koochyrat/comfort2
Currently my configuration.yaml file is :
#comfortalarm_control_panel:  - platform: mqtt    name: Comfort Alarm    state_topic: "comfort2/alarm"    command_topic: "comfort2/alarm/set"    availability_topic: "comfort2/alarm/online"    code_arm_required: true    code_disarm_required: true    payload_available: "1"    payload_not_available: "0"
AnyOne that can help?
Thanks

koochy_rat
Member
 

Joined: Saturday Apr 14th, 2018
Location:  
Posts: 9
Status: 
Offline

  back to top

This is the mapping from Home assistant:

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


ARM_HOME is for day mode. However Home assistant's UI does not have night mode, you have to find a way of adding that or use a different plugin.


UltraBB 1.172 Copyright © 2007-2014 Data 1 Systems