Python Plugin SetPoint device

Python and python framework

Moderator: leecollings

Post Reply
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Python Plugin SetPoint device

Post by micha_pr »

Hi,

using 3.6694 - compiled version.
Python is running fine.

Tried to create a plugin with SetPoint Thermostat - but something is wrong...

I have added a SetPoint device, all seems to be ok.

Changing the value in UI - using the "Edit" button - the value will be changed in UI - and in database.
Requesting the value from Python it will not be changed.
Only after restarting domoticz the last value will be shown.

I use normal debug while HeartBeat for testing:

Code: Select all

      Domoticz.Debug("Device:           " + str(x) + " - " + str(Devices[x]))
      Domoticz.Debug("Device ID:       '" + str(Devices[x].ID) + "'")
      Domoticz.Debug("Device Name:     '" + Devices[x].Name + "'")
      Domoticz.Debug("Device nValue:    " + str(Devices[x].nValue))
      Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
      Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
and get only the old value for sValue

Code: Select all

2017-02-12 19:40:21.525  (hz11) onHeartbeat called
2017-02-12 19:40:21.525  (hz11) 'HardwareID':'9'
2017-02-12 19:40:21.525  (hz11) 'Port':'80'
2017-02-12 19:40:21.525  (hz11) 'Address':'127.0.0.1'
2017-02-12 19:40:21.525  (hz11) 'Version':'1.0.0'
2017-02-12 19:40:21.525  (hz11) 'HomeFolder':'/var/tmp/domo/dev-domoticz/plugins/Hzg/'
2017-02-12 19:40:21.525  (hz11) 'Mode3':'True'
2017-02-12 19:40:21.525  (hz11) 'Key':'Hzg1'
2017-02-12 19:40:21.525  (hz11) 'Mode6':'Debug'
2017-02-12 19:40:21.526  (hz11) 'Author':'nobody'
2017-02-12 19:40:21.526  (hz11) 'Name':'hz11'
2017-02-12 19:40:21.526  (hz11) Device count: 1
2017-02-12 19:40:21.526  (hz11) Device:           1 - ID: 7, Name: 'hz11 - Heizung2Set', nValue: 2, sValue: '25.00'
2017-02-12 19:40:21.526  (hz11) Device ID:       '7'
2017-02-12 19:40:21.526  (hz11) Device Name:     'hz11 - Heizung2Set'
2017-02-12 19:40:21.526  (hz11) Device nValue:    2
2017-02-12 19:40:21.526  (hz11) Device sValue:   '25.00'
2017-02-12 19:40:21.526  (hz11) Device LastLevel: 0
Value was set to 22 (as sample) - and is in SQLite database right.

How can I request the right sValue from Element?

Even if I update the nValue (19) for this Element in SQLite database, do not get the right one back...

Code: Select all
7|9|0000009|1|hz11 - Heizung2Set|1|242|1|0|0|12|255|19|22.00|2017-02-12 19:21:17|7|0.0|1.0|0.0|1.0|||0|0|0||

UPDATE SOLUTION: (thanks to Dnpwwo):
Dnpwwo wrote:....That said, if you have a need to handle other things updating Domoticz values outside the plugin use:

Code: Select all

Devices[x].Refresh()
to force synchronization as required.
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

NEXT PROBLEM:

SetPoint device (same for switch) have an option "Timer"

Code: Select all

2017-02-13 20:02:01.915  Schedule item started! Name: hz16 - Heizung2Set, Type: On Time, ThermostatID: 18, Time: 2017-02-13 20:02:01
Timer is not updating the value - nothing happen, no event.

For Switch I will get an event:

Code: Select all

2017-02-13 20:10:01.979  Schedule item started! Name: hz16 - Status, Type: On Time, DevID: 19, Time: 2017-02-13 20:10:01
2017-02-13 20:10:02.016  (hz16) Calling message handler 'onCommand'.
2017-02-13 20:10:02.016  (hz16) onCommand called for Unit 3: Parameter 'Off', Level: 15
How this can be solved for SetPoint device?

Any idea?

THANKS!
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin SetPoint device

Post by Dnpwwo »

@micha_pr,

That might be a bug. I haven't done anything with timers and assumed they would update the same way that other parts of the system do.

I will have a look at it.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin SetPoint device

Post by Dnpwwo »

@micha_pr,

I set a timer on a Domoticz device controlled by a Python plugin and the onCommand was called as I expected.

I got a 'Set Level' command with a level of 99 on a slider.

Can you retry?
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Hi,

rechecked (with same build) with timers:

Code: Select all

FOR SWITCH:
2017-02-16 14:10:01.285  Schedule item started! Name: hz20 - Status, Type: On Time, DevID: 13, Time: 2017-02-16 14:10:01
2017-02-16 14:10:01.292  (hz20) Calling message handler 'onCommand'.
2017-02-16 14:10:01.292  (hz20) onCommand called for Unit 3: Parameter 'On', Level: 15

2017-02-16 14:12:01.304  Schedule item started! Name: hz20 - Status, Type: On Time, DevID: 13, Time: 2017-02-16 14:12:01
2017-02-16 14:12:01.337  (hz20) Calling message handler 'onCommand'.
2017-02-16 14:12:01.338  (hz20) onCommand called for Unit 3: Parameter 'Off', Level: 15

FOR SETPOINT DEVICE:
2017-02-16 14:12:58.954  Hardware Monitor: Fetching data (System sensors)
2017-02-16 14:13:01.314  Schedule item started! Name: hz20 - Heizung2Set, Type: On Time, ThermostatID: 12, Time: 2017-02-16 14:13:01
2017-02-16 14:13:01.963  (hz20) Calling message handler 'onHeartbeat'.
So, for setpoint device do not get anything...

Attached a simple plugin (have removed all not needed code - it will only add the devices and log)
plugin.txt
plugin.py (please rename) for testing setpoint device with timer
(4.44 KiB) Downloaded 163 times
I hope you can find out the issue ;)

Thanks!!
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin SetPoint device

Post by Dnpwwo »

@micha_pr,

It appears that SetPoint devices have their own special code in Domoticz which is why it is not being picked up.

I will look into it.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin SetPoint device

Post by Dnpwwo »

@micha_pr,

Pull Request #1242 has thermostat support built in. Once that is merged you shoud retry.

From the script you attached it looks like youare planning on doing socket and HTTP handling yourself. Do you realise the plugin framework has support for those built in?

Have a look at the Transport, Connect and Send commands on the help page http://www.domoticz.com/wiki/Developing_a_Python_plugin
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Hi,
nice, will try it when available :)
you are planning on doing socket and HTTP handling yourself
I will try of course to use features from plugin.

Need the IP address and port setting for the external unit, managing the heating componets.
Wanted to try at first "regular" method, then switch step by step to plugin ;)
In this time it is a Python script running with cron job - but I think it can be more interesting for other users if it will be a plug&play solution using your standard python plugin.

Will tell you when Setpoint is working ;)

Thank you!
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Setpoint device is working now, thanks!

But the other one (type 70 - Heating / Zone) have same issue, sorry.

I can update the device setting a new sValue, but it will not make any call if user will change the setpoint.
This device will be used to show the current temperature and setpoint + the current mode (custom, auto, permanent overwrite)

You can try same script as before.

Thanks again!

Michael
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin SetPoint device

Post by Dnpwwo »

@micha_pr,

I'm going to need more detail, hardware type 70 is:

Code: Select all

	HTYPE_OpenWebNetTCP,		//70
that doesn't seem to line up with what you are saming about heating (although I could be wrong!)
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Yes, maybe that in detail it is different ;)

I can update such device in normal case via JSON request (current solution - created via Hardware-evohome-zone) like

Code: Select all

http://[IP]:8080/json.htm?type=setused&idx=547&name=Thermostatxyz&description=&setpoint=16&mode=PermanentOverride&until=&used=true
Then the value will be changed.

Of course can also request the values.

With current device created by Python plugin would be needed same functionality ;)
thermostat.jpg
thermostat.jpg (20.36 KiB) Viewed 3438 times
THANKS!
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Dnpwwo wrote:@micha_pr,

I'm going to need more detail
Do you need something else from me? How I can help to integrate the device?

Thanks!
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Hi,

is there a chance to add this device into the Python plugin?

Or will be the best way to handle it via JSON scripting inside the script?
It's really a good add-on element for handle a thermostat for checking mode, setpoint and current temp of the device.

Thanks!
Michael
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
barbaar
Posts: 56
Joined: Wednesday 24 December 2014 16:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin SetPoint device

Post by barbaar »

Can you share your latest code? I'm thinking about creating a plugin for the Tado Thermostat, and this would be a great jumpstart ;)
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Hi,

I made a Homematic plugin, but because of missing "type 70 - Heating / Zone" have stopped.
Maybe will solve this with additional JSON call for adding the device - without the Heating/Zone it is not very comfortable.

In this time the door/window handle control (open/closed/tilted) is working fine, but didn't make the right symbols for this... (3 state)

I think it does not help for Tado Thermostat, because Homematic is another standard...

Michael
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python Plugin SetPoint device

Post by Dnpwwo »

@micha_pr,

I had another look at this and I think the problem is that Type 70 is not valid. The Type field maps on to the values in this file https://github.com/domoticz/domoticz/bl ... trx.h#L795 and valid thermostats types are (assuming my hex to decimal conversion is correct):
  • ...
  • 64 - Thermostat1
  • 65 - Thermostat2
  • 66 - Thermostat3
  • 67 - Thermostat4
  • 72 - Radiator1
  • ...
maybe you should try one of those. Valid SubTypes are shown as well.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Hmm....
Maybe my fault.... with this id.
Creating it with "json.htm?type=createevohomesensor&idx="+hwidx+"&sensortype=70"

in database looks like:
Thermostat - ID
Thermostat - ID
thermostat_db.PNG (8.58 KiB) Viewed 3032 times
Any idea?
Thanks!

Michael
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
micha_pr
Posts: 82
Joined: Friday 24 October 2014 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany, near Berlin
Contact:

Re: Python Plugin SetPoint device

Post by micha_pr »

Dnpwwo wrote:maybe you should try one of those.
Have rechecked the suggested device IDs - does not help:
heating_65_66_67.PNG
heating_65_66_67.PNG (22.41 KiB) Viewed 2976 times
Here are only switches present.
heating_70_64_72.PNG
heating_70_64_72.PNG (25.21 KiB) Viewed 2976 times
Only the "needed" device "70" have the "Set" option (Set setpoint)
heating_242.PNG
heating_242.PNG (10.24 KiB) Viewed 2976 times
This is the one working device - see above, you made it working.

Type 70 is defined here:
https://github.com/domoticz/domoticz/bl ... pes.h#L252 - if this help...

Thanks!
Michael
Michael Pruefer
----------------------------
http://www.zwave-review.com (German only)
http://www.SmartHome.Work (German only)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest