Comfort  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 393 times)

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

slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5493
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: 62
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 335 times)

Last edited on Monday May 28th, 2018 03: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 336 times)

Last edited on Monday May 28th, 2018 03: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 09: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: 546
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 03:11 pm by schford

wexfordman
UCM Pi Users
 

Joined: Monday Jan 1st, 2007
Location: Cork, Ireland
Posts: 546
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: 546
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 03: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: 546
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 178 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 03: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: 5493
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: 5493
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: 30
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: 5493
Status: 
Offline

  back to top

You would need UCM/Pi to use MQTT

theshepherdmatt
Member
 

Joined: Monday Jun 17th, 2019
Location:  
Posts: 30
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: 5493
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: 30
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.

wexfordman
UCM Pi Users
 

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

  back to top

Hi koochi, So I decided to abandon my openhab installation and try and move over to HASS, and see if I could implement your solution. Of course, Ive stumbled at the first hurdle again. I have installed HASS on a RPI3B, it is HASSOS/HASSIO, so i cannot SSH into it and run the commands to install mqtt client etc.

Any reccomendations I could look at to work around this ?

Ian
Member
 

Joined: Saturday Aug 19th, 2006
Location: United Kingdom
Posts: 249
Status: 
Offline

  back to top

I came across your script on Github, I didn't realise it was already a discussion on here!
I have it running and use it to interface to HomeSeer software - it works well.
Thank you.

wexfordman
UCM Pi Users
 

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

  back to top

I think my problem is I installed hassos, whereas I should have gone for hass supervised install, so will wipe and try again :-)

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

koochy_rat wrote: 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.

I'm partly sending this message in the hope of finding out if some of you are still watching this old thread... 
I've just starting using koochy_rat's great module and I'm looking through the code to investigate some issues and I wondered if any of you use the alarm arming functions?
Re. the quoted code above, I just noticed in the Comfort Protocol manual that it says that "m!" does a standard local arm of the system and "M!" does a remote arm. The example it gives of the difference is for Away Mode, where in local mode you are required to exit and in remote mode you are not.   I was just thinking that for Home Assistant, where the user might sometimes be controlling things from far away then surely "M!" would be better for setting Away mode (e.g. if you have temporarily alarmed and then want to re-arm the system once they've left)? 
I will do some more experimenting another day as the family are in bed now so arming and disarming the alarm would not make me very popular. :)

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

Also on this topic - does anyone know how to stop it reconnecting so often? The python module stays connected to Comfort for between 2 and 7 minutes on my system and then it tells me there is an "orderly shutdown" and it automatically reconnects after about 5 seconds.

There is no apparent pattern as there can be a motion event (for example) a few seconds before reconnection. Is this something I can configure on the Comfort end or is this normal behaviour that I just have to put up with?

It did seem to cause a race-condition type issue at least once when I just happened to press a button just as the Home Assistant entities were about to be declared Unavailable. The python script then failed with an unexpected exception. It looked like it didn't handle an incoming output status change during the re-connection? I kept the debug output so I may investigate that another day.

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

caravanboy wrote: Also on this topic - does anyone know how to stop it reconnecting so often? The python module stays connected to Comfort for between 2 and 7 minutes on my system and then it tells me there is an "orderly shutdown" and it automatically reconnects after about 5 seconds.

There is no apparent pattern as there can be a motion event (for example) a few seconds before reconnection. Is this something I can configure on the Comfort end or is this normal behaviour that I just have to put up with?

It did seem to cause a race-condition type issue at least once when I just happened to press a button just as the Home Assistant entities were about to be declared Unavailable. The python script then failed with an unexpected exception. It looked like it didn't handle an incoming output status change during the re-connection? I kept the debug output so I may investigate that another day.

Replying to myself - interestingly when there is no activity at all (e.g. overnight) it stays connected without problem

wexfordman
UCM Pi Users
 

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

  back to top

steefdebruijn wrote: 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
Anyone any tips or pointers on how to implement this on a RPI running HASSOS. I dont have the above directory ?
I notice my comfort connection only runs when I have terminal window open and when i start the comfort2.pi

Attachment: hassos.JPG (Downloaded 53 times)

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

If possible I'd run it separately to HASSOS - do they recommend running your own processes on the Home Assistant OS? If you did run it there you'd have to reinstall each time you upgraded HASSOS too.
If you just want to start it manually and leave it running in the background then use "&" to launch it in the background. Mine stays alive when I close my terminal if I run it like this. 

    python comfort.py &> mylogfile.log &


Alternatively, look at launching it with nohup to ensure it definitely stays alive.

I lazily had my comfort.py running for a long time in that way (i.e. without getting around to auto-launching), it is pretty reliable (and I've also fixed lots of unhandled message types in it) so you rarely have to restart it. I also made mine auto-reconnect to Home Assistant which it now does in most situations (still one scenario on my backlog not yet implemented).

wexfordman
UCM Pi Users
 

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

  back to top

Thanks Caravanboy

Sorry, Im a bit confused, my linux knowledge is fairly basic, i prettymuch follow line by line instructions where I can get them.

With HASSOS, I have enabled sambashare, and if i ssh into the rpi, it brings me to the root directory, and I then navigate to the config folder where I installed paho mqtt etc. My comfort2.py file is within this directory, and only when i can only run comfort2.py from this folder via ssh

so it works to this point, but again, only when I have the ssh window open adter running comfort2.py. When I close down the ssh window, then the entities go to unavailable state.

Not sure where to go from there ?

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

Ok, first try this then from your SSH Window:


python3 comfort2.py &> yourlogfile.log &


Then type 'exit' to close your command window.
If the entities still go unavailable, log back in to your terminal and look at the logfile and see if that gives any clues?

wexfordman
UCM Pi Users
 

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

  back to top

Thanks for that,
So I logged in via SSH, navigated to the config folder and ran the commands as you listed.The devices became available in HA, and I could see motion sensors being activated as i moved etc.
I then entered "exit" and got a reply saying that a process was still running, and entered it again to leave the terminal.
HA then stopped updating the sensors again once the terminal window was closed!The logfile is completely blank.
Thanks for help so far, really appreciate it.

Attachment: terminal screenshot.JPG (Downloaded 49 times)

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

Hmm, okay, the HA shells on HASSOS must behave differently to the shell on my NAS Container then.

So, what I would try next is putting the nohup command in front of your command line. 

If you're interested to understand what that's doing then this page explains it (and shows examples of correct syntax): nohup details

wexfordman
UCM Pi Users
 

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

  back to top

Ahh, perfect, that makes sense and appears to be working, very much appreciated.

How do I ensure that this starts up automatically now if my pi/ha restarts ?

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

Well... that's another question. You'd have to understand which flavour of Linux your HASSOS is based on to determine the right method of auto-starting processes. I used to know how to do this on UNIX variants a few years back (e.g. rc2.d folders etc) but it has all moved on a lot.

You could read some of the HA guidance here (which is aimed at helping you auto-start HA, but the principles would be similar). That said, as I mentioned above, an upgrade to HASSOS would possibly/probably lose that config.

Alternatively, I just spotted this add-on which may be more suited to achieving what you want?  Startup.d Addon

Hope this helps!

wexfordman
UCM Pi Users
 

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

  back to top

Again, thanks a million for thus, makes sense again and I will do a bit if research.

In your opinion, what's the best deployment to use for HASS, bearing in mind my limited knowledge of Linux, and dockers etc. Do you think it would make sense for me to try a different configuration rather than hassos ?

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

I think with limited knowledge HASSOS is probably the best choice - in theory it handles everything and is as almost as close to a turnkey solution as you can get for the basic Home Assistant (unless you buy one of their dedicated 'Blue' boxes).

I've got intermediate knowledge and I still use HASSOS. My NAS supports Virtual Machines so it was easy for me to just create a raw VM on there from a HASSOS image. Also likely much more easy to get community support for running HASSOS on a Pi too.

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 130
Status: 
Offline

  back to top

I'm really confused now. This is the second notification I've had on this thread today. The first time I logged in there didn't seem to be any new messages and now just a "thankyou" for something not obvious? :)
Although I see Skirtstrider also only made 1 post and also joined today (like the previous poster who caused my notification). Hmm...

Last edited on Monday May 23rd, 2022 02:38 pm by caravanboy

slychiu
Administrator


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

  back to top

Sorry its another spanner. He has been banned

wexfordman
UCM Pi Users
 

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

  back to top

Am having to recongure my home assistant, which to me, pretty much means learning all about home assistant again :-(

Wondering if anyone can help me. I have managed to get it up and running and reporting back sensor states, but having issues with the configuration.yaml file which I have stripped back to the bare minimum to get just 1 input working, see below.

What is not working, is the status of the input is appearing as offline/unavaiable.
So I am pretty sure the issue relates to the "availability topic", i am definatly missing it or having issues with the syntax, can anyone help with this ?


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes

# Text-to-speech
tts:
- platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

mqtt:
binary_sensor:
- name: "Front Door"
unique_id: "front door"
state_topic: "comfort2/input1"
availability:
- topic: "comfort2/alarm/online"
payload_available: "1"
payload_not_available: "0"
payload_on: "1"
payload_off: "0"

Ingo
UCM Pi Users


Joined: Sunday Jan 21st, 2007
Location: South Africa
Posts: 557
Status: 
Offline

  back to top

After seeing this thread I tried to get this going in a Docker using posixx/comfort2mqtt container which seems to be the same as KR's python script discussed here.
It actually works out-the-box but I noticed that Inputs were not published until the state changes. Using mqtt explorer I can see all the Outputs and Flags but none of the Inputs until I trigger one to change. I think the same goes for Counters as only my frequently changing Counters are visible. Maybe that is the issue you refer to. Not very helpful if it's indeed the case. Would be nice to incorporate the z and Z commands to force an update on startup.

wexfordman
UCM Pi Users
 

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

  back to top

Thanks,
I actually think I have it working. The config.yaml format in HA changed recently, I think it was listed as a breaking change, so needed to reconfigure this.
I also found that the available topic had to be correctly defined, which is why the inputs for ecxample were showing as unavailable, but would report a status change if movement was detected.
i will post up my updated yaml files for anyone interested once I get a decent set of sensors etc up and running.
My other issue, is that I am using a HASSOS install, which, if I am thinking correctly, is a docker type install, but without python etc, it is bare bones. So when I went to install the paho client and run the python comfort2.py it was failing. I think I have found away around this by using an addon ssh client which takes me to the docker level outside of hassos, and I can install from there. I know nothing about docker, I may have this completely wrong in my understanding, but it is working now it seems. I just need to do a few final checks to ensure it is auto starting and survivs a hass system update.

Ingo
UCM Pi Users


Joined: Sunday Jan 21st, 2007
Location: South Africa
Posts: 557
Status: 
Offline

  back to top

i will post up my updated yaml files for anyone interested once I get a decent set of sensors etc up and running.
Yes, please do. It would be nice to see what you've done.

wexfordman
UCM Pi Users
 

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

  back to top

ok,
Forgive any innacuracies or errors, I am not really good at linux/coding etc, so this is how I stumbled accross it.
First off, my installation is  home assistant supervised, installed onto a rpi 3 using the standard install image.
The problem with this install, is I beleive that it is a "containerised" install, is heavily locked down, and does not have many of the linux applications etc installed to allow you run koochies install, so some modifications are required. Please feel free to expand on any of my poiints below (either by correction or explaining what is happening which would be helpful to those of us without the detailed understanding).
So, first off, what I think I am doing, is this. SSH into HA. I do this via an ssh add on, but not the normal one. The normal ssh add on takes you to the HA container, which is not suitable for this purpose (please forgive me if this is not the correct explanation, but it is what I think is the explanation).

I use an add on called "advanced ssh and web terminal"
Once installed (from the addon store) TURN OFF PROTECTION MODE and ENABLE SHOW IN SIDEBAR"

Then start the addon.(it is slow to start)

the comfort2.py file koochie provided needs edited and be saved in the config folder. I do this, by enabling samba share and then using windows to connect to it like a network drive/folder, i edit the file with notepad then.
once comfort2.py is edited and installed, then in HA

Click on the TERMINAL

and use  koochys 2 commands:pip3 install paho-mqtt

Followed by:

python3 config/comfort2.py

you should then see the terminal startup and connect to comfort and report back.


The configuration.yaml file now needs to be updated, as the format is different from when koochie wrote his documentation. I am pasting my file below, which is/was done by trial and error, so it works. You need to do this to ensure the entities get created and mapped to the correctr comfort inputs etc. "
# Loads default set of integrations. Do not remove.
 default_config:

# Load frontend themes from the themes folder
 frontend:
  themes: !include_dir_merge_named themes

# Text-to-speech
 tts:
  - platform: google_translate

 automation: !include automations.yaml
 script: !include scripts.yaml
 scene: !include scenes.yaml
# Example configuration.yaml entry

 mqtt:
  binary_sensor:
    - name: "Front Door"
      unique_id: "front door"
      state_topic: "comfort2/input1"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Kitchen Door"
      unique_id: "Kitchen door"
      state_topic: "comfort2/input2"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Back Door"
      unique_id: "Back door"
      state_topic: "comfort2/input3"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Office Door"
      unique_id: "Office door"
      state_topic: "comfort2/input4"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Hall Motion"
      unique_id: "Hall Motion"
      state_topic: "comfort2/input5"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Corridoor Motion"
      unique_id: "Corridoor Motion"
      state_topic: "comfort2/input6"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Kitchen Motion"
      unique_id: "Kitchen Motion"
      state_topic: "comfort2/input7"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Den Motion"
      unique_id: "Den Motion"
      state_topic: "comfort2/input8"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Utility Motion"
      unique_id: "Utility Motion"
      state_topic: "comfort2/input9"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Office Motion"
      unique_id: "Office motion"
      state_topic: "comfort2/input10"
      payload_on: "1"
      payload_off: "0"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
    - name: "Bathroom Motion"
      unique_id: "Bathroom Motion"
      state_topic: "comfort2/input11"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Ciaran Motion"
      unique_id: "Ciaran Motion"
      state_topic: "comfort2/input12"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Guest Motion"
      unique_id: "Guest Motion"
      state_topic: "comfort2/input13"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Master Bedroom Motion"
      unique_id: "Master Bedroom Motion"
      state_topic: "comfort2/input14"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "En Suite Motion"
      unique_id: "En Suite Motion"
      state_topic: "comfort2/input15"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "En Suite Door"
      unique_id: "En Suite Door"
      state_topic: "comfort2/input16"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Dressing Room Door"
      unique_id: "Dressing Room Door"
      state_topic: "comfort2/input17"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Kelly Motion"
      unique_id: "Kelly Motion"
      state_topic: "comfort2/input18"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "Living Room Motion"
      unique_id: "Living Room Motion"
      state_topic: "comfort2/input19"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
    - name: "En Suite Door"
      unique_id: "En Suite door"
      state_topic: "comfort2/input24"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      payload_on: "1"
      payload_off: "0"
  alarm_control_panel:
    - name: "Comfort Alarm"
      unique_id: "Comfort Alarm"
      state_topic: "comfort2/alarm"
      command_topic: "comfort2/alarm/set"
      availability_topic: "comfort2/alarm/online"
      payload_available: "1"
      payload_not_available: "0"
      code: "1234"  #code can be different from Comfort's


that seems to work for me. The last bit is to get it to autostart, which I havent done yet, but will see if it works now in a while and post back.
I think the 2 key things here are with the standarad supervised install, you need to use an elevated version of ssh to get access to run the commands koochie has shown and the second point is the yaml file sytnax has changed to something like what I have posted above.




Last edited on Saturday Jun 17th, 2023 01:23 pm by wexfordman

Ingo
UCM Pi Users


Joined: Sunday Jan 21st, 2007
Location: South Africa
Posts: 557
Status: 
Offline

  back to top

Looks good!!

wexfordman
UCM Pi Users
 

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

  back to top

Right, so I have decided to move the comfort2.py service over to a seperate RPI, so that HASS can run on its own and independently, and I can worry less about it being a non standard install.

I have (actually what I did was use a ucmp, wiped it and installed Raspberry OS lite on it, which is headless).

I installed paho-mqtt, worte the comfort2.py file etc, and got everyhitn working


I then followed the instructions to get it to autostart on reboot, and am falling down here.

So the comnfort2.py is installed in home/eamon/comfort2.py

Looking at the auto start command then, my file in systemd ( /etc/systemd/system/comfort2@pi.service) should be

"[Unit]
Description=Comfort 2
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/usr/bin/python3 /home/eamon/comfort2.py

[Install]
WantedBy=multi-user.target"

Now, i can manually start comfort2.py and everyhting is ok, but it is not autostarting on a reboot ?

Anyone see what I am doing wrong here ?
I am also finding that the comfort2.py stops running the second I close the terminal to the machine. I tried the nohup command "nohup python3 comfort2.py" but that doest seem to do it!

Last edited on Sunday Jun 18th, 2023 07:51 pm by wexfordman

Sota
UCM Pi Users
 

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

  back to top

Did you enable the autostart with "systemctl enable comfort2"?

Also, run dmesg after boot up to check for any errors.

posixx
Member
 

Joined: Saturday Jul 8th, 2006
Location:  
Posts: 24
Status: 
Offline

  back to top

Hello,

Just to let you know; i have created an addon for home assistant to have everything set up automatically.

You can add my addon repository to the addon store: https://github.com/posixx/hass_addons

addon name = Comfort 2 MQTT. You only have to configure ip, port and PIN.

Feel free to use!

slychiu
Administrator


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

  back to top

Thanks Posixx.  Thats interesting!

wexfordman
UCM Pi Users
 

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

  back to top

Thats fantastic, thanks so much.
Can I ask a possible adaption/change might be looked at. I am getting comms failures on my comfort system which I do need to fix but having problems as its a house iwring issue I think. 
When the comms failure is reported, home assistant changes the state of the alarm to "triggered", is there any way to avoid this ?


UltraBB 1.172 Copyright © 2007-2014 Data 1 Systems