Plugwise circle / stealth - plugin
Moderator: leecollings
-
- Posts: 9
- Joined: Sunday 16 June 2019 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands / Hilversum
- Contact:
Plugwise circle / stealth - plugin
Hi all
Just wanted to share a plugin I wrote thusfar (not my best work ) Since I seem unable find how to create a wiki account, I just post it here. This plugin communicates with the stretch (unlike the plugwise2py, which communicates directly with the USB-stick) and allow basis switch operations and logging of current power consumption. No total usage at this moment.
Step 1: create a folder under the domoticz\plugins, called Plugwise. Another name will require a change in the python code.
Step 2: create a file "plugin.py" in this folder, containing the code below (in plugin.txt, as the form does not allow .py files).
Step 3: restart domoticz
Step 4: add hardware (Plugwise should be in the hardware list). Setup parameters....
- Devices should be added to the setup upon start of the plugin.
Step 5: add unused devices to the UI.
Note: In the plugin folder, a file is created 'devices.json'. This file contains the link between circle/sensor and unitid in domoticz. Do _not_ deleted (unused) devices in domoticz or this file if you do not know what you are doing as this will case a mismatch between plugwise/plugin/domoticz. Also, if debug is enabled, a log.txt file is created. As my experience is that when you make a mistake as a developer, domoticz UI is unresponsive and you cannot access the internal log.
Reset:
If you made a mess: delete the 'hardware', delete the devices.json and repeat from step 4.
This is provided as-is, feel free to use this as you please and extend on it. Do try to help the community and publish any improvements, please.
Just wanted to share a plugin I wrote thusfar (not my best work ) Since I seem unable find how to create a wiki account, I just post it here. This plugin communicates with the stretch (unlike the plugwise2py, which communicates directly with the USB-stick) and allow basis switch operations and logging of current power consumption. No total usage at this moment.
Step 1: create a folder under the domoticz\plugins, called Plugwise. Another name will require a change in the python code.
Step 2: create a file "plugin.py" in this folder, containing the code below (in plugin.txt, as the form does not allow .py files).
Step 3: restart domoticz
Step 4: add hardware (Plugwise should be in the hardware list). Setup parameters....
- Devices should be added to the setup upon start of the plugin.
Step 5: add unused devices to the UI.
Note: In the plugin folder, a file is created 'devices.json'. This file contains the link between circle/sensor and unitid in domoticz. Do _not_ deleted (unused) devices in domoticz or this file if you do not know what you are doing as this will case a mismatch between plugwise/plugin/domoticz. Also, if debug is enabled, a log.txt file is created. As my experience is that when you make a mistake as a developer, domoticz UI is unresponsive and you cannot access the internal log.
Reset:
If you made a mess: delete the 'hardware', delete the devices.json and repeat from step 4.
This is provided as-is, feel free to use this as you please and extend on it. Do try to help the community and publish any improvements, please.
Last edited by ghulleman on Saturday 16 November 2019 21:52, edited 3 times in total.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Plugwise circle / stealth - plugin
Please contact @Gizmocuz via forum PM to get a WIKI account. Creation of new accounts is temporary disabled because of large amounts of SPAM user creations attacks.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 113
- Joined: Sunday 14 July 2013 22:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: NL
- Contact:
Re: Plugwise circle / stealth - plugin
great, but got some errors:
at the first start I saw all my plugs in the domoticz log passing.
What to do next?
thanks, Jeroen
Code: Select all
2019-11-12 16:09:24.733 Status: (Plugwise) Started.
2019-11-12 16:09:25.569 (Plugwise) Loading parameters
2019-11-12 16:09:25.570 (Plugwise) Loading appliances from stretch
2019-11-12 16:09:25.562 Status: (Plugwise) Entering work loop.
2019-11-12 16:09:25.563 Status: (Plugwise) Initialized version 1.0.0, author 'Gerrit Hulleman'
2019-11-12 16:09:40.408 Error: (Plugwise) 'onHeartbeat' failed 'KeyError'.
2019-11-12 16:09:40.408 Error: (Plugwise) ----> Line 371 in '/home/pi/domoticz/plugins/Plugwise/plugin.py', function onHeartbeat
2019-11-12 16:09:40.408 Error: (Plugwise) ----> Line 181 in '/home/pi/domoticz/plugins/Plugwise/plugin.py', function onHeartbeat
2019-11-12 16:09:40.408 Error: (Plugwise) ----> Line 284 in '/home/pi/domoticz/plugins/Plugwise/plugin.py', function getModuleDataFromNode
2019-11-12 16:09:49.946 (Plugwise) onHeartbeat called
at the first start I saw all my plugs in the domoticz log passing.
Code: Select all
2019-11-12 16:14:04.993 Status: (Plugwise) Started.
2019-11-12 16:14:05.827 (Plugwise) Loading parameters
2019-11-12 16:14:05.828 (Plugwise) Loading appliances from stretch
2019-11-12 16:14:05.818 Status: (Plugwise) Entering work loop.
2019-11-12 16:14:05.819 Status: (Plugwise) Initialized version 1.0.0, author 'Gerrit Hulleman'
2019-11-12 16:14:09.014 (Plugwise) Processing appliances
2019-11-12 16:14:09.015 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.017 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.017 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.018 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.019 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.020 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.021 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.021 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.022 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.023 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.024 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.024 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.025 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.026 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.027 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.028 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.028 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.029 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.030 (Plugwise) Appliance found: xxxx - xxxx
2019-11-12 16:14:09.031 (Plugwise) Loading mapped devices from config file
2019-11-12 16:14:09.031 (Plugwise) 0 devices loaded from configuration file
2019-11-12 16:14:09.032 (Plugwise) 'Language':'nl'
2019-11-12 16:14:09.032 (Plugwise) 'Mode6':'Debug'
2019-11-12 16:14:09.032 (Plugwise) 'Name':'Plugwise'
2019-11-12 16:14:09.032 (Plugwise) 'Address':'192.168.2.17'
2019-11-12 16:14:09.032 (Plugwise) 'Key':'PlugwiseStretch'
2019-11-12 16:14:09.032 (Plugwise) 'Port':'0'
2019-11-12 16:14:09.032 (Plugwise) 'Database':'/home/pi/domoticz/domoticz.db'
2019-11-12 16:14:09.032 (Plugwise) 'DomoticzVersion':'4.11468'
2019-11-12 16:14:09.032 (Plugwise) 'StartupFolder':'/home/pi/domoticz/'
2019-11-12 16:14:09.032 (Plugwise) 'HardwareID':'38'
2019-11-12 16:14:09.032 (Plugwise) 'Author':'Gerrit Hulleman'
2019-11-12 16:14:09.032 (Plugwise) 'UserDataFolder':'/home/pi/domoticz/'
2019-11-12 16:14:09.033 (Plugwise) 'HomeFolder':'/home/pi/domoticz/plugins/Plugwise/'
2019-11-12 16:14:09.033 (Plugwise) 'DomoticzHash':'xxxx'
2019-11-12 16:14:09.033 (Plugwise) 'Mode1':'10'
2019-11-12 16:14:09.033 (Plugwise) 'Password':'xxxxxx'
2019-11-12 16:14:09.033 (Plugwise) 'Version':'1.0.0'
2019-11-12 16:14:09.033 (Plugwise) 'DomoticzBuildTime':'2019-11-05 16:05:44'
2019-11-12 16:14:09.033 (Plugwise) 'Username':'stretch'
2019-11-12 16:14:09.033 (Plugwise) Device count: 0
2019-11-12 16:14:09.033 (Plugwise) Last unitId : 0
2019-11-12 16:14:09.034 (Plugwise) Heartbeat : 10
2019-11-12 16:14:09.035 (Plugwise) Plugin operational
thanks, Jeroen
-
- Posts: 9
- Joined: Sunday 16 June 2019 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands / Hilversum
- Contact:
Re: Plugwise circle / stealth - plugin
Line 284 which causes can be commented out. It was used during debugging and seems no longer used.
I believe you have some hardware that I do not have in your system. My setup only has circles, senses, a button and stealths. Line 284 retrieves the 'type' of devices, which is present in my modules.
Try logging the 'ModuleNode' parameter and check the XML.
I believe you have some hardware that I do not have in your system. My setup only has circles, senses, a button and stealths. Line 284 retrieves the 'type' of devices, which is present in my modules.
Try logging the 'ModuleNode' parameter and check the XML.
-
- Posts: 113
- Joined: Sunday 14 July 2013 22:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: NL
- Contact:
Re: Plugwise circle / stealth - plugin
I'm using circles only, It looks like something is wrong and causes this main heartbeat error unfortunately.ghulleman wrote: ↑Wednesday 13 November 2019 8:33 Line 284 which causes can be commented out. It was used during debugging and seems no longer used.
I believe you have some hardware that I do not have in your system. My setup only has circles, senses, a button and stealths. Line 284 retrieves the 'type' of devices, which is present in my modules.
Try logging the 'ModuleNode' parameter and check the XML.
2019-11-13 13:28:58.852 Error: (Plugwise_stretch) 'onHeartbeat' failed 'KeyError'
-
- Posts: 113
- Joined: Sunday 14 July 2013 22:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: NL
- Contact:
Re: Plugwise circle / stealth - plugin
somehow no file is created also:
Note: In the plugin folder, a file is created 'devices.json'. This file contains the link between circle/sensor and unitid in domoticz. Do _not_ deleted (unused) devices in domoticz or this file if you do not know what you are doing as this will case a mismatch between
@ghulleman, can you please assist?
BR, Jeroen
Note: In the plugin folder, a file is created 'devices.json'. This file contains the link between circle/sensor and unitid in domoticz. Do _not_ deleted (unused) devices in domoticz or this file if you do not know what you are doing as this will case a mismatch between
Code: Select all
2019-11-15 09:01:35.993 Status: (Plugwise_stretch) Started.
2019-11-15 09:01:36.834 (Plugwise_stretch) Loading parameters
2019-11-15 09:01:36.834 (Plugwise_stretch) Debug logging mask set to: NONE
2019-11-15 09:01:36.834 (Plugwise_stretch) Loading appliances from stretch
2019-11-15 09:01:36.825 Status: (Plugwise_stretch) Entering work loop.
2019-11-15 09:01:36.825 Status: (Plugwise_stretch) Initialized version 1.0.0, author 'Gerrit Hulleman'
2019-11-15 09:01:40.039 (Plugwise_stretch) Processing appliances
2019-11-15 09:01:40.044 (Plugwise_stretch) Loading mapped devices from config file
2019-11-15 09:01:40.045 (Plugwise_stretch) 0 devices loaded from configuration file
2019-11-15 09:01:40.045 (Plugwise_stretch) Plugin operational
2019-11-15 09:01:51.390 Error: (Plugwise_stretch) 'onHeartbeat' failed 'KeyError'.
2019-11-15 09:01:51.390 Error: (Plugwise_stretch) ----> Line 371 in '/home/pi/domoticz/plugins/Plugwise/plugin.py', function onHeartbeat
2019-11-15 09:01:51.390 Error: (Plugwise_stretch) ----> Line 181 in '/home/pi/domoticz/plugins/Plugwise/plugin.py', function onHeartbeat
2019-11-15 09:01:51.390 Error: (Plugwise_stretch) ----> Line 284 in '/home/pi/domoticz/plugins/Plugwise/plugin.py', function getModuleDataFromNode
BR, Jeroen
-
- Posts: 9
- Joined: Sunday 16 June 2019 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands / Hilversum
- Contact:
Re: Plugwise circle / stealth - plugin
I have updated the plugin and added two things:
1. Try catch, so modules that do not process correctly will not stop the plugin
2. Dump the module-XML causing the problem (only if debug mode is enabled).
This will not fix the issue, but it will give me some details on why this is not working for you people. Please provide the XML in the log that causes the error.
If this does not work, please uncomment lines 180 and 181 and try to send the entire xml file.
1. Try catch, so modules that do not process correctly will not stop the plugin
2. Dump the module-XML causing the problem (only if debug mode is enabled).
This will not fix the issue, but it will give me some details on why this is not working for you people. Please provide the XML in the log that causes the error.
If this does not work, please uncomment lines 180 and 181 and try to send the entire xml file.
-
- Posts: 113
- Joined: Sunday 14 July 2013 22:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: NL
- Contact:
Re: Plugwise circle / stealth - plugin
Great thanks!ghulleman wrote: ↑Friday 15 November 2019 21:50 I have updated the plugin and added two things:
1. Try catch, so modules that do not process correctly will not stop the plugin
2. Dump the module-XML causing the problem (only if debug mode is enabled).
This will not fix the issue, but it will give me some details on why this is not working for you people. Please provide the XML in the log that causes the error.
If this does not work, please uncomment lines 180 and 181 and try to send the entire xml file.
a lot of the same errors caught for each plugs I have currently installed:
Code: Select all
Exception caught
<module id="xxxxx">
<vendor_name>Plugwise</vendor_name>
<vendor_model>NR</vendor_model>
<hardware_version>6539-0701-4023</hardware_version>
<firmware_version>2011-06-27T10:52:18+02:00</firmware_version>
<created_date>2016-12-22T20:19:46.844+01:00</created_date>
<modified_date>2019-02-02T10:14:29.198+01:00</modified_date>
<deleted_date />
<services>
<electricity_point_meter id="xxxxxx">
<measurement directionality="consumed" log_date="2019-02-02T10:14:29.134+01:00" unit="W">11.47</measurement>
<measurement directionality="produced" log_date="2019-02-02T10:14:29.134+01:00" unit="W">0.00</measurement>
</electricity_point_meter>
<electricity_interval_meter id="xxxxx">
<measurement directionality="consumed" interval="PT1H" log_date="2019-02-02T10:00:00+01:00" unit="Wh">2.70</measurement>
<measurement directionality="produced" interval="PT1H" log_date="2019-02-02T10:00:00+01:00" unit="Wh">0.00</measurement>
</electricity_interval_meter>
<relay id="xxxxx">
<measurement log_date="2019-02-02T10:14:06.451+01:00">on</measurement>
</relay>
</services>
<protocols>
<network_router id="xxxxx"><mac_address>000D6F0000xxxxx</mac_address><network id="xxxxx" /></network_router>
</protocols>
</module>
-
- Posts: 9
- Joined: Sunday 16 June 2019 10:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands / Hilversum
- Contact:
Re: Plugwise circle / stealth - plugin
It was the modelname. The XML returned from my stretch returned with an attribute. The file has been updated in the original post. Please let me know if this works for you.
-
- Posts: 113
- Joined: Sunday 14 July 2013 22:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: NL
- Contact:
Re: Plugwise circle / stealth - plugin
Yes! Almost there!! , got all the Plugs (missing 1) in Domoticz as a device.
2019-11-17 09:16:14.255 (Plugwise_stretch) Exception caught
2019-11-17 09:16:14.268 (Plugwise_stretch) <module id="8f030ae42df54f5b9a1xxxxxxxxx">
2019-11-17 09:16:14.268 <vendor_name>Plugwise</vendor_name>
LOG XML for this:
Code: Select all
Exception caught
<module id="8f030ae42df54f5b9a1xxxxxxxxxx">
<vendor_name>Plugwise</vendor_name>
<vendor_model>NC</vendor_model>
<hardware_version />
<firmware_version />
<created_date>2016-01-09T20:21:28.380+01:00</created_date>
<modified_date>2016-12-22T17:07:51.122+01:00</modified_date>
<deleted_date />
<services>
<electricity_point_meter id="48fa5647622046aaa1c34f74f2xxxxxx">
</electricity_point_meter>
<relay id="8f673845818e478aae5fc94525xxxxx">
</relay>
<electricity_interval_meter id="674293332f4e4c8390958fd0exxxxx">
</electricity_interval_meter>
</services>
<protocols>
<network_coordinator id="965f231030d74815823962xxxxxxx"><mac_address>000xxxxxxxx</mac_address><network id="d49d49f054b346409d5xxxxx" /></network_coordinator>
</protocols>
</module>
Can you avoid this error in the Plugwise plugin?
Can you fix this also?
thanks in advance!
regards,
Jeroen
-
- Posts: 5
- Joined: Thursday 03 December 2020 17:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v2024.7
- Contact:
Re: Plugwise circle / stealth - plugin
Thank you for this, works like a charm.
I am, however, also trying to get the Energy logging going.
Therefor I would like to read data from the Domoticz.db
Unfortunately I have little experience with Python.
In line 239 near the bottom of the def onHeartbeat(self): section the following command updates a record in the database:
self.updateDevice(deviceUnitId, 0, str(valDouble)+';0', True)
There has to be a similar command to read the sValue from the DeviceStatus table in the db.
After that I want to recalculate that value and update the table with that new value.
However I can't figure out the syntax for a read or get command.
Any assistance would be very welcome.
I am, however, also trying to get the Energy logging going.
Therefor I would like to read data from the Domoticz.db
Unfortunately I have little experience with Python.
In line 239 near the bottom of the def onHeartbeat(self): section the following command updates a record in the database:
self.updateDevice(deviceUnitId, 0, str(valDouble)+';0', True)
There has to be a similar command to read the sValue from the DeviceStatus table in the db.
After that I want to recalculate that value and update the table with that new value.
However I can't figure out the syntax for a read or get command.
Any assistance would be very welcome.
Re: Plugwise circle / stealth - plugin
Plugwise heeft een doorstart gemaakt, waardoor er geen grafieken van energieverbruik meer worden aangeboden via de Plugwise app. Als alternatief kun je terugvallen op Source, maar dan moet je de Stick uit de Stretch halen, waardoor je de app niet meer kunt gebruiken en die is wel handig voor actuele data en schakelschema's.
Ik ben op zoek naar een manier om de Stretch uit te lezen en dan zelf de verbruiken van de circles op te slaan. Kan dat via Domoticz zonder extra hardware of de stick uit de Stretch te halen?
Ik ben op zoek naar een manier om de Stretch uit te lezen en dan zelf de verbruiken van de circles op te slaan. Kan dat via Domoticz zonder extra hardware of de stick uit de Stretch te halen?
-
- Posts: 13
- Joined: Monday 01 February 2021 16:33
- Target OS: Linux
- Domoticz version: V2024.7
- Location: Netherlands
- Contact:
Re: Plugwise circle / stealth - plugin
I have a combined bash script and pearl script to get the values from the smile and calculate 5 minutes W averages. The smile has about each 8 seconds a new value for used and produced Watt. So averaging this during 5 minutes and multiplying this by 5/60=1/12 gives the produced/consumed Wh.
One can do the same thing in the Python script, provided the heartbeat is set to less than 8, say 6 seconds. The previous time of the measure of the Watt value should be saved and the value forgotten if this time is the same as the current time. The Wh calculated each 5 minutes should be stored in the location where the widget shows the produced(-)/consumed(+) Wh during that day. When the day ends the Wh value starts from 0.
My problem is where and how this Wh value should be stored.
One can do the same thing in the Python script, provided the heartbeat is set to less than 8, say 6 seconds. The previous time of the measure of the Watt value should be saved and the value forgotten if this time is the same as the current time. The Wh calculated each 5 minutes should be stored in the location where the widget shows the produced(-)/consumed(+) Wh during that day. When the day ends the Wh value starts from 0.
My problem is where and how this Wh value should be stored.
-
- Posts: 13
- Joined: Monday 01 February 2021 16:33
- Target OS: Linux
- Domoticz version: V2024.7
- Location: Netherlands
- Contact:
Re: Plugwise circle / stealth - plugin
Just found out that in the line:
one needs to replace the zero in ";0" by the value of the used/produced energy in Wh.
Will develop the necessary python code to show the use/production during the day.
Code: Select all
self.updateDevice(deviceUnitId, 0, str(valDouble)+';0', True) # force update...
Will develop the necessary python code to show the use/production during the day.
-
- Posts: 13
- Joined: Monday 01 February 2021 16:33
- Target OS: Linux
- Domoticz version: V2024.7
- Location: Netherlands
- Contact:
Re: Plugwise circle / stealth - plugin
I managed to change the code so used/produced energy is accounted for. Could not get previous counter values from the database, but I use a file for each device to keep track of the counter value. I have no idea how to upload the new source.
-
- Posts: 13
- Joined: Monday 01 February 2021 16:33
- Target OS: Linux
- Domoticz version: V2024.7
- Location: Netherlands
- Contact:
Re: Plugwise circle / stealth - plugin
The hack with the file to store the previous counter value is not needed.
Devices[unitID].sValue contains the previous stored sValue, which contains two numbers: Watt and counter.
So Devices[unitID].sValue.split(';')[1] gives you the previous value of the total Wh used/produced.
Devices[unitID].sValue contains the previous stored sValue, which contains two numbers: Watt and counter.
So Devices[unitID].sValue.split(';')[1] gives you the previous value of the total Wh used/produced.
Who is online
Users browsing this forum: No registered users and 1 guest