- Notifications
You must be signed in to change notification settings - Fork0
Domoticz Mochad bridge assistant for X10 dim/bright packets
License
sigmdel/mochas
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Domoticzmochad bridgeassistant for dim/bright packets
A Python3 script to handle X10 bright/dim packets for dimmable devices in Domoticz
Version 0.5 (2024-03-10)
FR : Le billet intituléDes appareils sans fil X10 refusent de mourir contient plus d'information sur ce sujet.
mochad
is "a Linux TCP gateway daemon for the X10 CM15A RF (radio frequency) and PL (power line) controller and the CM19A RF controller"source. All X10 power line and wireless packets received by a controller are retransmitted through TCP socket connections bymochad
. However, theDomoticzMochad CM15Pro/CM19A bridge with LAN interface decodes only the On and Off packets received frommochad
. Dim and Bright packets result in a decode error:
Error: Mochad: Cannot decode 'Rx RF House: J Func: Bright'
This script contains a user-defined dictionary of X10 units numbers and corresponding Domoticiz idx numbers for dimmable devices. It also keeps track of the last used X10 unit number. When a Dim/Bright packet is received, it attempts to decrease/increase the level of the last used X10 unit. It does this by obtaining the current light level of the corresponding device using theDomoticz HTTP/JSON API and then sets the new modified light level using the same API.
Themochas
add-on service has been used with a CM15A controller which handles RF packets only. Consequently, RF packets from the CM19A should work, but no test has been done with PL packets that could be sent bymochad
if that controller is used. Assuming that the only difference between RF and PL packets generated bymochad
is the two-letter source label,
02/01 18:57:11 Rx RF HouseUnit: J1 Func: On02/01 18:57:15 Rx PL HouseUnit: J3 Func: On
then, starting with version 0.4,mochas
should also work with power line X10 packets sent bymochad
if connected to a CM15A. Again, this has not been tested.
Starting with version 0.5mochas
offers support for thesecurity provisions introduced in Domoticz 2023.1.
It remains the case that only IPv4 host addresses are used.
Testing was done on a first generation Raspberry Pi B circa 2011 running bothmochas
andmochad
. The operation system was Raspberry Pi OS Lite (32-bit) (2024-01-25) for armhf with a 6.1.0 Linux kernel.
By default,mochas
assumes Domoticz security settings are set at the lowest possible level. No user name and password are provided when using the Domoticz API with plain text HTTP requests. For this to workDomoticz
andmochas
must be on the same subnet which, in turn, must be included in theTrusted Networks (no username/password) in theDomoticz Security
settings.
With version 0.5,mochas
no longer needs to be on a trusted network. In that case, HTTP or HTTPS requests sent to Domoticz must contain the name and password of aDomoticz user with admin rights. The credentials must be a "username:password" base64 encoded string specified as an option in themochas.json
configuration file.
"CREDS64":"cG9uZG1pc3Q6c2VhYnJlYXpl"
Insecure HTTP requests (the default inmochas
) with credentials will be ignored by Domoticz unless
[] Allow Basic-Auth authentication over plain HTTP (API only)
is checked inAPI Protection of theDomoticz Security
settings.
In no way should base64 encoding be viewed as secure. It iseasily verified that the above example corresponds to the string "pondmist:seabreaze". Consequently if that option is used with HTTP requests, it amounts to sending the credentials as plain text in an HTTP header.
Starting with version 0.5, secure HTTP requests are enabled with
"TLS":true
in themochas.json
configuration file. Because the digital certificate supplied with Domoticz is self-signed, verification will fail unless the self-signed certificate is replaced with a certificate from a recognized authority or if CA verification is disabled inmochas
with the
"VERIFY":false
option in themochas.json
configuration file.
mochas
- the executable Python3 script that should be installed in/usr/local/bin/
.mochas.json.template
- a model JSON configuration file that should be modified and installed in/etc/mochas/
asmochas.json
.mochad.service
- the systemd service file that could be installed in/etc/systemd/system/
.
Ifmochas
is installed in a directory other than the one suggested,ExecStart
inmochad.service
must be modified accordingly.
Onlyroot
, the owner ofmochas
in/usr/local/bin
, should have read, write, and execute permissions over the script:# sudo chmod 700 mochas
The configuration file is JSON formatted. Here is the template which will have to be edited.
{"LOGLEVEL":"error","HOST":"192.168.168.168","PORT":1099,"HOUSE":"J","DELTA":15,"CREDS64":"","TLS":false,"VERIFY":true,"DOMOTICZ":"192.168.168.168:8080","DEVICES": {"6":66,"7":177,"8":288 }}
Type | Key | Value |
---|---|---|
m/s | LOGLEVEL | system log level, one of : "error", "info" or "debug". |
m/s | HOST | mochad IP address. |
m/i | PORT | mochad TCP port. It is hard-coded in the mochad source so unlikely to change. |
m/s | HOUSE | Monitored X10 house code, a letter from "A" to "P". |
m/i | DELTA | Absolute value of the change in the light level to be applied when a Dim or Bright packet is received. The light level is an integer from 0 to 100, so the delta value should be considerably less than 50 and greater than 0 of course. |
o/s | CREDS64 | base64 encoded "user:password" credentials of a Domoticz user with admin rights. Default: "" (none). |
o/b | TLS | When true encrypted HTTPS requests are forwarded to Domoticz, otherwise plain text HTTP requests are used. The TCP port specified in the DOMOTICZ value must be correct. Default: false . |
o/b | VERIFY | When true, the digital certificate returned by Domoticz will be verified. This value will have to be explicitely set to false if the self-signed certificate provided with Domoticz has not been replaced by a certificate from a recognized certificate authority. This value is ignored if TLS is false. Default: true |
m/s | DOMOTICZ | Domoticz IP address and TCP port. There is no default value for the port and it must correspond with the insecure or secure HTTP protocol specified with theTLS setting. |
m/s | DEVICES | Map of key:value pairs where the key is a X10 unit number (from "1" to "16") and its value is the Domoticz light sensor idx number of the corresponding dimmable light. |
Note
Type: an entry can be mandatory (m) or optional (o). The value can be a string (s), an integer (i), or a boolean (b). The default value will be used if the optional value is not present.
The presence of the mandatory keys is verified when the configuration file is loaded. There is no validity check of the values performed at that time.
If installingmochad
on a recent Linux distribution withsystemd
, such as Raspberry Pi OS, thenhttps://github.com/sigmdel/mochad might be a good fork to try.
About
Domoticz Mochad bridge assistant for X10 dim/bright packets
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.