Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comfort2MQTT with Home Assistant Part 2 - MQTT
#1
The MQTT architecture according to mqqtt.org is shown below




MQTT Brokers and Clients
  • Clients publish messages to a topic on an MQTT broker.
  • The Broker distributes these messages to any clients subscribed to that topic.
This model allows for efficient message exchange in real-time, which is why it\'s widely used in smart homes, industrial automation, and other IoT applications.
Home Assistant is the Broker (installed by Add-on)Clients include Comfort, and Mobile phones.

The following MQTT topics are published (by Comfort):the MQTT published topics ae used to show status in Home Assistant
  • comfort2mqtt/alarm - current MQTT alarm state (disarmed, pending, armed_home, armed_away, armed_night, arm_vacation, triggered) 
  • comfort2mqtt/alarm/online - '1' for online, '0' for offline comfort2mqtt/alarm/message - Informational messages, e.g. the zone that triggered an alarm
  • comfort2mqtt/alarm/timer - countdown entry/exit timer in seconds when arming to away mode or entering. updates every second.
  • comfort2mqtt/alarm/status - Status of the alarm (Idle, Trouble, Alert, Alarm
  • comfort2mqtt/alarm/bypass - List of Bypassed zones. EG. 1,3,5,7,9. '0' indicates no bypassed zones.
  • comfort2mqtt/alarm/LWT - Online or Offline text status 
  • comfort2mqtt/alarm/refresh - Trigger a refresh of all objects. Used when a refresh of all object states are required.
  • comfort2mqtt/alarm/connected - Status of LAN Connection to Comfort. \'1\' when connected and logged in
  • comfort2mqtt/alarm/doorbell - '0' for off/answered or '1' for on
  • comfort2mqtt/alarm/mode - Integer values for current Alarm Mode. 0 - 4 (Off, Away, Night, Day, Vacation), See Comfort M? or MD documentation.
  • comfort2mqtt/input<1 to 96>; (Zone Input) have the following JSON attributes EG.     { "Time": "2024-06-12T15:12:42", 
  •     "Name": "GarageDoor",
        "ZoneWord": "Garage Door", 
        "State": 0,          
        "Bypass": 0
      } 
comfort2mqtt/input<129 to 248> (SCS/RIO Input) have the following JSON attributes EG. 
  { "Time": "2024-06-12T15:12:44", 
    "Name": "ScsRioResp129", 
    "ZoneWord": null, 
    "State": 0,
    "Bypass": null
   } 
  • comfort2mqtt/output<1 to 96> (Zone Output) have the following JSON attributes EG. 
      {
         \"Time\": \"2024-06-12T15:12:44\",
         \"Name\": \"Output01\", 
         \"State\": 0
      } 
  • comfort2mqtt/output<129 to 248> (SCS/RIO Output) have the following JSON attributes EG.
      { 
         \"Time\": \"2024-06-12T15:12:45\",
         \"Name\": \"ScsRioOutput129\",
        \"State\": 0
       } 
  • comfort2mqtt/flag<1 to 254> have the following JSON attributes EG.
      {
         \"Time\": \"2024-06-12T15:12:46\",
         \"Name\": \"Flag01\", 
         \"State\": 0
       } 
  • comfort2mqtt/sensor<0 to 31> have the following JSON attributes EG. 
       {
         \"Time\": \"2024-06-12T17:16:54\",
         \"Name\": \"Sensor01\",
         \"Value\": 0
       } 
  • comfort2mqtt/counter<0 to 254> have the following JSON attributes EG.
       {
         \"Time\": \"2024-06-12T15:12:49\",
         \"Name\": \"Counter000\",
         \"Value\": 0,
         \"State\": 0
        }
    *Note: \'State\' 1 for On, 0 for Off. State is set to 1 when Value is non-zero. Used for lighting as this indicates On|Off status while Value could indicate brightness
The following MQTT topics are subscribed (Home Assistant  to Comfort) TheMQTT subscried topics are for commands to Comfort from Home assistant
  • comfort2mqtt/alarm/set - sent from Home Assistant, DISARM, ARMED_HOME, ARMED_NIGHT, ARMED_VACATION or ARMED_AWAY 
  • comfort2mqtt/alarm/refresh - sent from Home Assistant, <Key> triggers a complete object refresh 
  • comfort2mqtt/alarm/battery_update - sent from Home Assistant, <id> triggers a battery update query \'D?id01 and D?id02 id\'s 1,33-37 are supported for Main and Slaves when ARM CPU is detected. 
  • comfort2mqtt/input<1 to 96>/set - 1 for open/active, 0 for closed/inactive. Settable if zone is a Virtual input 
  • comfort2mqtt/input<129 to 248>/set 
  • comfort2mqtt/output<1 to 96>/set - 0=off, 1=on, 2=change state , 3 = Pulse Output for 1 second, 4 - Flash Output at 1 sec On/Off rate 
  • comfort2mqtt/output<129 to 248>/set 
  • comfort2mqtt/response<1 to 1024>/set - value is ignored. Comfort response is activated as programmed in Comfigurator 
  • comfort2mqtt/flag<1 to 254>/set - 1 for on, 0 for off 
  • comfort2mqtt/counter<0 to 254>/set - 16-bit value 
  • comfort2mqtt/sensor<0 to 31>/set - 16-bit value
#2
Use File Editor (on the Sidebar) to edit the configuration.yaml file

The default configuration.yaml file is below, should not be changed.




add new entries to configuration.yaml. These entries will appear on the dashboard.

The following should be added to the file under the default entries:
mqtt:
  alarm_control_panel:
   - name: Comfort Alarm
     unique_id: \"comfort2_alarm_a46ee0\"  # E.G. Use last six digits of UCM/Eth03 MAC address to make it unique
     code_arm_required: false
     qos: 2
     supported_features:
       - arm_home
       - arm_away
       - arm_night
        # - arm_vacation
       - arm_custom_bypass
     state_topic: \"comfort2mqtt/alarm\"
     command_topic: \"comfort2mqtt/alarm/set\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     payload_available: 1
     payload_not_available: 0
     code: \"1234\"  # onscreen keypad  Code can be different from Comfort\'s. 
                          #This code is for the onscreen Keypad to Disarm, while the Comfort code in Comfort2MQTT configuration is to login to Comfort itself.
[color=\"#ff0000\"]#This onscreen keypad  code is used in the alarm Keypad to disarm Comfort. It is not the #Comfort user code, although both can be set to the same code. When you enter the #onscreen keypad  code in the alarm Keypad to disarm, Comfort2MTT will disarm the #security by using the saved user code.  [/color]                    
                    # Secrets can be used EG. \"code: !secret comfort_pin

  sensor:
   - name: Alarm Mode
     unique_id: \"comfort2_alarm_mode\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     state_topic: \"comfort2mqtt/alarm\"
     payload_available: \"1\"
     payload_not_available: \"0\"

   - name: Alarm Message
     unique_id: \"comfort2_alarm_message\"
     state_topic: \"comfort2mqtt/alarm/message\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     payload_available: \"1\"
     payload_not_available: \"0\"

Note that indentations are very important in the yaml file. Items on the same level should have the same indentation level, Use Spaces, not Tabs.

eg  mqtt: is at the top level indentation.

at the next level are
       comfort alarm sensor:        
       sensor:            
       binary sensor:             light: 
Under each of the above, the next level has
        name:             followed by several lines eg       
        unique_id: \"comfort2_alarm_mode\"  #any unique name can be used  
        availability_topic: \"comfort2mqtt/alarm/online\" # this is the availabilty status
        state_topic: \"comfort2mqtt/alarm\"#this gives the state to be monitored eg alarm state
        payload_available: \"1\"  #contents of the comfort2mqtt/alarm/online topic for available state
        payload_not_available: \"0\"  #contents of the comfort2mqtt/alarm/online topic for unavailable state




#3
Go to Setting > Devices and Services. You can see MQTT under Discovered (depending on the version) . Enable  it

In Settings> Devices, and Services > Devices, you should see the screen below. It shows devices Comfort II Ultra (MQTT client), Comfort2QTT (Home Assistant Add-on) , Comfort2MTTBridge (MQTT client)


The values for these entities are retrieved from both the Comfort system as well as the alarm configuration CCLX file. If the CCLX file is not present then no object enrichment will be done and default names will be used for entities, especially ZoneWord strings and Object Descriptions as per the CCLX file.  The CCLX file should be placed in the Home Assistant /addon_configs/<xxxxcomfort2mqtt> folder. Ie a folder wth comfort2mqtt in the name which includes comfort2mqtt.




The subdirectory has comfort2mqtt in the name


Upload the cclx file to that subdirectory
The cclx file will provide names in the cclx file for zone names in messages eg zone name which is open during arming o the zone that caused the alarm Withut the cclx file, only the zone number will be shown








#4
In configuration.yaml

This configuration text   sensor:
   - name: Alarm Mode
     unique_id: \"comfort2_alarm_mode\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     state_topic: \"comfort2mqtt/alarm\"
     payload_available: \"1\"
     payload_not_available: \"0\"

   - name: Alarm Message
     unique_id: \"comfort2_alarm_message\"
     state_topic: \"comfort2mqtt/alarm/message\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     payload_available: \"1\"
     payload_not_available: \"0\"

will cause this to be shown in the dashboard - (Overview)




 

the following config adds 3 binary sensors; Dining PIR, Landing PIR, Front door to the dashboard

  binary_sensor:
   - name: Dining PIR
     unique_id: \"comfort2_input3\"
     state_topic: \"comfort2mqtt/input3\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     value_template: \'{{ value_json.State }}\'
     json_attributes_topic: \"comfort2mqtt/input3\"
     json_attributes_template: \'{{ value_json | tojson }}\'
     payload_on: \"1\"
     payload_off: \"0\"
     payload_available: \"1\"
     payload_not_available: \"0\"
     device_class: motion


   - name: Landing PIR
     unique_id: \"comfort2_input2\"
     state_topic: \"comfort2mqtt/input2\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     value_template: \'{{ value_json.State }}\'
     json_attributes_topic: \"comfort2mqtt/input2\"
     json_attributes_template: \'{{ value_json | tojson }}\'
     payload_on: \"1\"
     payload_off: \"0\"
     payload_available: \"1\"
     payload_not_available: \"0\"
     device_class: motion


   - name: Front Door
     unique_id: \"comfort2_input1\"
     state_topic: \"comfort2mqtt/input1\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     value_template: \'{{ value_json.State }}\'
     json_attributes_topic: \"comfort2mqtt/input1\"
     json_attributes_template: \'{{ value_json | tojson }}\'
     payload_on: \"1\"
     payload_off: \"0\"
     payload_available: \"1\"
     payload_not_available: \"0\"
     device_class: door 

The sensors can be grouped into Areas eg Living Room, Landing, bedroom etc..





The lights shown have not been added in the config yet, this will be done later
Output control
this is under light:

  light:
   - name: Test Light Output
     unique_id: \"comfort2_output7\"
     state_topic: \"comfort2mqtt/output7\"
     state_value_template: \'{{ value_json.State }}\'
     command_topic: \"comfort2mqtt/output7/set\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     payload_on: \"1\"
     payload_off: \"0\"
     payload_available: \"1\"
     payload_not_available: \"0\"
     qos: 0
     retain: false

Flag Control
  also under light: but light: should not be repeated

   - name: Test Flag
     unique_id: \"comfort2_flag7\"
     state_topic: \"comfort2mqtt/flag7\"
     state_value_template: \'{{ value_json.State }}\'
     command_topic: \"comfort2mqtt/flag7/set\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     #json_attributes_topic: \"comfort2mqtt/flag7\"
     #json_attributes_template: \'{{ value_json | tojson }}\'
     payload_on: \"1\"
     payload_off: \"0\"
     payload_available: \"1\"
     payload_not_available: \"0\"
     qos: 0
     retain: false 

The dashboard shows the items under light: category..



Counter Control
  - name: Kitchen Light
     unique_id: \"comfort2_counter117\"
     state_topic: \"comfort2mqtt/counter117\"
     state_value_template: \'{{ value_json.State }}\'
     command_topic: \"comfort2mqtt/counter117/set\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     json_attributes_topic: \"comfort2mqtt/counter117\"
     json_attributes_template: \'{{ value_json | tojson }}\'
     payload_on: \"1\"
     payload_off: \"0\"
     payload_available: \"1\"
     payload_not_available: \"0\"
     brightness_scale: \"255\"
     brightness_value_template: \'{{ value_json.Value }}\'
     brightness_state_topic: \"comfort2mqtt/counter117\"
     brightness_command_topic: \"comfort2mqtt/counter117/set\"
     optimistic: false
     on_command_type: \"brightness\" 

In this case the counter control has been placed in the Kitchen Area.




Counters, flags, and sensors are important as they are used for 3rd party interfacing in Comfort, eg for KNX, cbus  and Modbus UCMS. 

The cnfiguration.yaml file used in these examples is attached, for reference


Attached Files
.yaml   configuration.yaml (Size: 6.25 KB / Downloads: 5)
#5
Keypad Arm and Disarm
  alarm_control_panel:
   - name: Comfort Alarm
     unique_id: \"comfort2_alarm_a46ee0\" # E.G. Use last six digits of UCM/Eth03 MAC address to make it unique
     code_arm_required: false
     qos: 2
     supported_features:
       - arm_home
       - arm_away
       - arm_night
        # - arm_vacation
       - arm_custom_bypass
     state_topic: \"comfort2mqtt/alarm\"
     command_topic: \"comfort2mqtt/alarm/set\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     payload_available: 1
     payload_not_available: 0
     code: \"1234\"  # Code can be different from Comfort\'s. This code is for the Add-on while the Comfort code is to login to Comfort itself.
                    # Note: If the Comfort User Code does not allow Disarm then the Add-on will not be able to Disarm.
                    # Secrets can be used EG. \"code: !secret comfort_pin 





The # key to force arm is not present here as this is not a standard feature of the alarm_control_panel . Instead a CUSTOM  BYPASS BUTTON can be created. 


See http://www.comfortforums.com/forum143/5592.html on how to create this alarm_control_panel
#6
The status of the connection, firmware, serial numbers etc can be seen by using MQTT





#7
Virtual Inputs

In Comfort, Virtual Inputs can be controlled by commands by external UCMs like KNX, Modbus, and Cbus. eg  KNX 1 bit group addresses can be mapped to Virtual inputs so that when the KNX object is turned on, it also forces the Comfort Virtual Input to follow the state of the KNX device which could be a KNX motion sensor. This allows external systems to act like comfort inputs in the alarm system. 

When z zone is virtual, the physical input will have no effect.

You can send commands in the comfort protocol by USB or Ethernet , eg I!2101  - Slave 1 Input 1 On I!2700 - Slave 2 Input 7 Off
Virtual Inputs mapped to external UCMs are set to Virtual automatically  when the mapping is done. If not mapped to exernal UCMs Inputs can be made virual using Comfigurator Inputs/ Zones screen by checking the Virtual box.  Virtual inputs are applicable to Inputs 17 and above (ie in Slaves) - not in CM9001 and its LEM
You can control Virtual Inputs in Home Assistant 
Under mqtt:
  switch:
    - name: Front Door Virtual Input
      unique_id: \"comfort2_virtual_input17/set\"
      state_topic: \"comfort2mqtt/input17\"
      value_template: \'{{ value_json.State }}\'
      command_topic: \"comfort2mqtt/input17/set\"
      availability_topic: \"comfort2mqtt/alarm/online\"
      json_attributes_topic: \"comfort2mqtt/input17\"
      json_attributes_template: \'{{ value_json | tojson }}\'
      payload_on: \"1\"
      payload_off: \"0\"
      payload_available: \"1\"
      payload_not_available: \"0\"
The 2nd Virtual Input front door below does not change - I do not know why it apears


Attached Files Thumbnail(s)
   
#8
You can add a binary sensor to monitor the actual state of the Front Door Virtual Input

binary sensor:
   - name: Front Door
     unique_id: \"comfort2_input17\"
     state_topic: \"comfort2mqtt/input17\"
     availability_topic: \"comfort2mqtt/alarm/online\"
     value_template: \'{{ value_json.State }}\'
     json_attributes_topic: \"comfort2mqtt/input17\"
     json_attributes_template: \'{{ value_json | tojson }}\'
     payload_on: \"1\"
     payload_off: \"0\"
     payload_available: \"1\"
     payload_not_available: \"0\"
     device_class: door
This will turn on and off according to the Switch Virtual input



Attached Files Thumbnail(s)
   
#9
For part 2B go to http://www.comfortforums.com/forum143/5592.html 



Questions and comments in   http://www.comfortforums.com/forum143/5592.html


Forum Jump:


Users browsing this thread: 2 Guest(s)