Comfort  Automation/ Security System Forums Home
Home Search search Menu menu Not logged in - Login | Register

Comfort 2 Alarm working with Home Assistant!
 Moderated by: slychiu Page:  First Page Previous Page  1  2  3  4  Next Page Last Page  
 New Topic   Reply   Printer Friendly 
 Rating:  Rating
AuthorPost
 Posted: Monday Feb 8th, 2021 06:24 pm
   PM  Quote  Reply 
41st Post
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 :-)



 Posted: Sunday Feb 21st, 2021 09:04 pm
   PM  Quote  Reply 
42nd Post
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. :)



 Posted: Monday Feb 22nd, 2021 03:45 pm
   PM  Quote  Reply 
43rd Post
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.



 Posted: Tuesday Feb 23rd, 2021 07:41 am
   PM  Quote  Reply 
44th Post
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



 Posted: Sunday Feb 27th, 2022 12:02 pm
   PM  Quote  Reply 
45th Post
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)



 Posted: Monday Feb 28th, 2022 07:57 am
   PM  Quote  Reply 
46th Post
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).



 Posted: Monday Feb 28th, 2022 01:36 pm
   PM  Quote  Reply 
47th Post
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 ?



 Posted: Monday Feb 28th, 2022 02:30 pm
   PM  Quote  Reply 
48th Post
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?



 Posted: Tuesday Mar 1st, 2022 08:47 am
   PM  Quote  Reply 
49th Post
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)



 Posted: Tuesday Mar 1st, 2022 09:26 am
   PM  Quote  Reply 
50th Post
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



 Posted: Tuesday Mar 1st, 2022 09:43 am
   PM  Quote  Reply 
51st Post
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 ?



 Posted: Tuesday Mar 1st, 2022 09:53 am
   PM  Quote  Reply 
52nd Post
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!



 Posted: Wednesday Mar 2nd, 2022 07:28 pm
   PM  Quote  Reply 
53rd Post
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 ?



 Posted: Thursday Mar 3rd, 2022 07:30 am
   PM  Quote  Reply 
54th Post
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.



 Posted: Monday May 23rd, 2022 02:37 pm
   PM  Quote  Reply 
55th Post
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



 Posted: Monday May 23rd, 2022 02:53 pm
   PM  Quote  Reply 
56th Post
slychiu
Administrator


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

  back to top

Sorry its another spanner. He has been banned



 Posted: Tuesday Jun 13th, 2023 08:55 pm
   PM  Quote  Reply 
57th Post
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"



 Posted: Wednesday Jun 14th, 2023 09:35 am
   PM  Quote  Reply 
58th Post
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.



 Posted: Wednesday Jun 14th, 2023 04:05 pm
   PM  Quote  Reply 
59th Post
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.



 Posted: Wednesday Jun 14th, 2023 07:14 pm
   PM  Quote  Reply 
60th Post
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.



 Current time is 08:48 pmPage:  First Page Previous Page  1  2  3  4  Next Page Last Page  
Top




UltraBB 1.172 Copyright © 2007-2014 Data 1 Systems