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 341 times)

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

slychiu
Administrator


Joined: Saturday Apr 29th, 2006
Location: Singapore
Posts: 5242
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: 34
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 284 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 285 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: 541
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: 541
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: 541
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: 541
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 163 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: 5242
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: 5242
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: 5242
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: 5242
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: 541
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: 223
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: 541
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: 123
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: 123
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: 123
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: 541
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 27 times)

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 123
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: 541
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: 123
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: 541
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 23 times)

caravanboy
Member
 

Joined: Wednesday Mar 8th, 2017
Location: United Kingdom
Posts: 123
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: 541
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: 123
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: 541
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: 123
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: 123
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: 5242
Status: 
Offline

  back to top

Sorry its another spanner. He has been banned


UltraBB 1.172 Copyright © 2007-2014 Data 1 Systems