Page 3 of 5

Re: Toon Energy Readings on Domoticz

Posted: Sunday 10 January 2016 21:08
by marcoheijkoop
HansieNL wrote:Got it working. I did setup an event as you told me how to do and that works, but now I use the lua script from PD0SBH. The script also set the switch if setpoint is changed on Toon thermostat.
Thanks for helping.
Hi Hansie,

Can you explain what you did?
I have the dummy switches working.
But i can't get the LUA working

Best regards, Marco

Re: Toon Energy Readings on Domoticz

Posted: Friday 22 January 2016 11:16
by MatthijsPH
If anyone is still interested in getting the current state directly from Toon I managed to alter the script that was placed on Github by rvdm. RVDM has done some awesome work!
To make a few modifications I forked the script, results can be found here.

How to get the current State from Toon into Domoticz

1. Create a uservariable in Domoticz
variable type: integer
variable value: can be any discrete number. Consider starting with 8. Toon state can only be 0 to 4, so if you install the script correct you should notice certain change.

2. Make sure you’ve got Python & Git installed on your rpi or synology
I run Domoticz on my Synology NAS and installed the pachages using ipkg.
After installation it's easy, for instance:

Code: Select all

ipkg install git
3. Install the (python) Toon module

Code: Select all

git clone https://github.com/mphagenaars/toon.git
cd toon
python setup.py install
4. modify toon2domoticz.py
Inside the Toon folder you will find a script named toon2domoticz.py. You can copy this script to a location of your choice. Mine is placed inside the domoticz/var/scripts folder.
Make sure you can execute the script:

Code: Select all

chmod 755 toon2domoticz.py

Or use a tool like WinSCP to set permissions.
You need to edit just two lines inside the script. Most easy way to edit would be to use WinSCP, but off course you can also use VI or any other editor of your choice

Code: Select all

domoticzserver = "your_ip_here:port"
uservariable = "name_of_uservar"
for instance

Code: Select all

domoticzserver = "192.168.1.50:8084"
uservariable = "varToonState"
5. execute the script
username & password are the same as you use to log on to https://toonopafstand.eneco.nl

Code: Select all

toon2domoticz.py -U your_username_here -P your_password_here
If you installed everything correct the uservariable should now be changed to the current Toon state.

The uservar can change into 5 different Eneco Toon states:
RELAX (comfort) = 0,
ACTIVE (thuis) = 1
SLEEP (slapen) = 2
AWAY (weg) = 3
HOLIDAY (vakantie) = 4

I’ve scheduled the script to run every 5 minutes on my Synology NAS. You can do the same on your rpi using cron.

You can now use the current Toon state inside your Blockly or LUA scripts
I also added this information to the wiki

Re: Toon Energy Readings on Domoticz

Posted: Saturday 23 January 2016 12:53
by gielie
I did exact as you suggested but it doesn't work (also on a synology 415play), this is the error i get.
I used the same directories and names you did.

Code: Select all

 Traceback (most recent call last):
  File "toon2domoticz.py", line 15, in <module>
  from Toon import Toon
  File "/volume1/@appstore/domoticz/var/scripts/toon/Toon.py", line 6, in <module>
  import requests
ImportError: No module named requests
Endor> 

Re: Toon Energy Readings on Domoticz

Posted: Sunday 24 January 2016 19:21
by MatthijsPH
Did you complete all steps without any errors prior to running the script?
So Python and Git are installed on your NAS and you were able te clone the script from github and run setup.py without any errors?
Can you find files named toon.py + toon.pyc in the Python folder on your NAS (on my synology it's /lib/python2.7/site-packages and it's also in /lib/python2.7)?


I didn't read carefully the first time.

Code: Select all

ImportError: No module named requests
It seems that python module requests is not installed. I think the solution is posted here

Re: Toon Energy Readings on Domoticz

Posted: Tuesday 26 January 2016 12:51
by gielie
MatthijsPH wrote:Did you complete all steps without any errors prior to running the script?
So Python and Git are installed on your NAS and you were able te clone the script from github and run setup.py without any errors?
Can you find files named toon.py + toon.pyc in the Python folder on your NAS (on my synology it's /lib/python2.7/site-packages and it's also in /lib/python2.7)?


I didn't read carefully the first time.

Code: Select all

ImportError: No module named requests
It seems that python module requests is not installed. I think the solution is posted here
I have the module requests installed but still no luck.

Code: Select all

 Traceback (most recent call last):
  File "toon2domoticz.py", line 15, in <module>
    from Toon import Toon
  File "/volume1/@appstore/domoticz/var/scripts/toon/Toon.py", line 6, in <module>
    import requests
ImportError: No module named requests
Endor> pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /lib/python2.7/site-packages
Endor> 
You said you copied the toon2domoticz to you script folder, but i guess you also copied toon.py


OK i got it, it seems that i had 2 versions of python running, one in @appstore and one in de lib/python2.7, its working now, tnks

Re: Toon Energy Readings on Domoticz

Posted: Tuesday 26 January 2016 15:34
by MatthijsPH
gielie wrote: [...]
OK i got it, it seems that i had 2 versions of python running, one in @appstore and one in de lib/python2.7, its working now, tnks
Okay, great to hear you've managed to get it working!

Re: Toon Energy Readings on Domoticz

Posted: Sunday 31 January 2016 23:16
by pixiard
I did all steps as well, really like to use this functionality. Unfortunately, I get this error:
Am I still missing anything?

Code: Select all

Traceback (most recent call last):
  File "./toon2domoticz.py", line 33, in <module>
    state = toon.get_program_state()
  File "/home/pi/domoticz/scripts/Toon.py", line 108, in get_program_state
    self.retrieve_toon_state()
  File "/home/pi/domoticz/scripts/Toon.py", line 77, in retrieve_toon_state
    self.toonstate = r.json()
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 799, in json
    return json.loads(self.text, **kwargs)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Re: Toon Energy Readings on Domoticz

Posted: Friday 05 February 2016 13:47
by wssmith
I have Toon 'scenes' working using the 4 dummy switches and was looking how to get this working using a 'selector' switch. Has anyone got this working yet? Perhaps using this latest script with uservariable it is even easier?

Re: Toon Energy Readings on Domoticz

Posted: Friday 05 February 2016 13:56
by kurniawan77
wssmith wrote:I have Toon 'scenes' working using the 4 dummy switches and was looking how to get this working using a 'selector' switch. Has anyone got this working yet? Perhaps using this latest script with uservariable it is even easier?

Yep
Toon selector
Toon selector
Knipsel.PNG (21.92 KiB) Viewed 4460 times

Re: Toon Energy Readings on Domoticz

Posted: Friday 05 February 2016 14:09
by wssmith
kurniawan77 wrote:Yep
Cool! Care to explain how you did it? Does it just read the 'scene' when set on Toon itself or can it also be used to set the 'scene'?

Still struggling with my first selector switch to run ventilation 10 or 30 min. Not perfect yet, so not really attempted Toon selector yet.

Re: Toon Energy Readings on Domoticz

Posted: Friday 05 February 2016 15:31
by kurniawan77
wssmith wrote:
kurniawan77 wrote:Yep
Cool! Care to explain how you did it? Does it just read the 'scene' when set on Toon itself or can it also be used to set the 'scene'?

Still struggling with my first selector switch to run ventilation 10 or 30 min. Not perfect yet, so not really attempted Toon selector yet.

The selectors gets updated by the Toon's setpoint (this also can be done by Toon2Domoticz) through lua script.

Code: Select all

if (ThermostatSetPoint == TemperatureHome) then
        --print("SetPoint equals Home temperature");
		if (otherdevices['Toon scenes'] ~= 'Home') then
		print("Updating Toon scenes selector to Home")
		commandArray['UpdateDevice']='idx|nValue|sValue'
end
return commandArray
--  nValue = 1 = on; sValue = Level (0,10,20,30...)
This way it doesn't execute the on action behind the switch. It does when you click on the switch!

Re: Toon Energy Readings on Domoticz

Posted: Friday 05 February 2016 15:40
by kurniawan77
delete... dp (double post :P )

Re: Toon Energy Readings on Domoticz

Posted: Sunday 07 February 2016 13:52
by gdg16
I have used the script of MatthijsPH and it's working perfectly. I also made a selector switch with the json url's to control the Toon scenes. Now i want to control the Toon by using the below event. For the event i made an extra variable "ToonProgramEvent" to make sure the event isn't running continuously.
Event_Toon.jpg
Event_Toon.jpg (278.29 KiB) Viewed 4421 times
The problem is, the event script isn't updating the selector switch. Does anaybody know how to control the selector switch from the event? Do i need to use the level number of the selector switch or the name?
Toon_selector_switch.jpg
Toon_selector_switch.jpg (9.24 KiB) Viewed 4421 times

Re: Toon Energy Readings on Domoticz

Posted: Sunday 07 February 2016 14:17
by gdg16
gdg16 wrote:I have used the script of MatthijsPH and it's working perfectly. I also made a selector switch with the json url's to control the Toon scenes. Now i want to control the Toon by using the below event. For the event i made an extra variable "ToonProgramEvent" to make sure the event isn't running continuously.

The problem is, the event script isn't updating the selector switch. Does anaybody know how to control the selector switch from the event? Do i need to use the level number of the selector switch or the name?
Already got it working :D to set the level of a selector switch you need to use "Level % ..".
Event_Toon.jpg
Event_Toon.jpg (291.13 KiB) Viewed 4421 times

Re: Toon Energy Readings on Domoticz

Posted: Monday 08 February 2016 14:01
by Markie
can everyone help me

Code: Select all

pi@raspberrypi ~/toon $ /home/pi/toon/toon2domoticz.py -U *********** -P ***********
Traceback (most recent call last):
  File "/home/pi/toon/toon2domoticz.py", line 31, in <module>
    toon.login()
  File "/home/pi/toon/Toon.py", line 35, in login
    self.sessiondata = r.json()
TypeError: 'dict' object is not callable
pi@raspberrypi ~/toon $
I get the above error how can I fix this does anyone know anything?

Mark

Re: Toon Energy Readings on Domoticz

Posted: Wednesday 10 February 2016 9:55
by gielie
kurniawan77 wrote:
wssmith wrote:
kurniawan77 wrote:Yep
Cool! Care to explain how you did it? Does it just read the 'scene' when set on Toon itself or can it also be used to set the 'scene'?

Still struggling with my first selector switch to run ventilation 10 or 30 min. Not perfect yet, so not really attempted Toon selector yet.

The selectors gets updated by the Toon's setpoint (this also can be done by Toon2Domoticz) through lua script.

Code: Select all

if (ThermostatSetPoint == TemperatureHome) then
        --print("SetPoint equals Home temperature");
		if (otherdevices['Toon scenes'] ~= 'Home') then
		print("Updating Toon scenes selector to Home")
		commandArray['UpdateDevice']='idx|nValue|sValue'
end
return commandArray
--  nValue = 1 = on; sValue = Level (0,10,20,30...)
This way it doesn't execute the on action (if you have one) behind the switch. It does when you click on the switch/selector!
Im new with domoticz and i cant figure out how you have done this.
I have my Toon working and i created the 4 setpoints wich are switchable and the on/off status gets changed by a blocky event but i cant figure out how to create a selector like you did and the way it gets changed without executing the action.

could you explain more step by step for dummies like me how and what you did to get the selector working like you have.
Maybe you can put this info in the wiki.

Re: Toon Energy Readings on Domoticz

Posted: Wednesday 10 February 2016 20:38
by MatthijsPH
gielie wrote:
kurniawan77 wrote:
wssmith wrote: [...]
Im new with domoticz and i cant figure out how you have done this.
I have my Toon working and i created the 4 setpoints wich are switchable and the on/off status gets changed by a blocky event but i cant figure out how to create a selector like you did and the way it gets changed without executing the action.

could you explain more step by step for dummies like me how and what you did to get the selector working like you have.
Maybe you can put this info in the wiki.
Go to settings --> hardware
In the drop-down menu choose "Dummy (Does nothing, use for virtual switches only)" and name it any way you like (if you haven't already created dummy hardware).
You should now see your dummy hardware in de list above.
Click "create virtual sensor" and then pick "selector switch" at the bottom. Name it anyway you like, for instance ToonScenes.
You can find the new selector switch on the switches tab. Here you can edit the switch to meet your demands.

Re: Toon Energy Readings on Domoticz

Posted: Thursday 11 February 2016 13:51
by gielie
MatthijsPH wrote:
gielie wrote:
kurniawan77 wrote:
Go to settings --> hardware
In the drop-down menu choose "Dummy (Does nothing, use for virtual switches only)" and name it any way you like (if you haven't already created dummy hardware).
You should now see your dummy hardware in de list above.
Click "create virtual sensor" and then pick "selector switch" at the bottom. Name it anyway you like, for instance ToonScenes.
You can find the new selector switch on the switches tab. Here you can edit the switch to meet your demands.
Ok, i got the selector, i put the 4 setpoints in there with their corresponding scripts to put them on.
I have the Toon setpoint named "Room Setpoint", so i renamed this in your script, i named the room temp "Huiskamer", so i changed this also in the script. So my script looks like this now.

Code: Select all

if (Room Setpoint == Huiskamer) then
        --print("SetPoint equals Home temperature");
      if (otherdevices['Toon scenes'] ~= 'Home') then
      print("Updating Toon scenes selector to Home")
      commandArray['UpdateDevice']='idx|nValue|sValue'
end
return commandArray
--  nValue = 1 = on; sValue = Level (0,10,20,30...)
Its not working, what is wrong?

Could you post the complete code and the name of your switches so I can compare.

Re: Toon Energy Readings on Domoticz

Posted: Sunday 21 February 2016 22:07
by marcoheijkoop
I'm getting this error when following above steps

Code: Select all

Traceback (most recent call last):
  File "/usr/local/domoticz/var/scripts/toon2domoticz.py", line 33, in <module>
    state = toon.get_program_state()
  File "/usr/lib/python2.7/site-packages/Toon.py", line 108, in get_program_state
    self.retrieve_toon_state()
  File "/usr/lib/python2.7/site-packages/Toon.py", line 72, in retrieve_toon_state
    raise Exception('Incomplete response')
Exception: Incomplete response

Re: Toon Energy Readings on Domoticz

Posted: Sunday 21 February 2016 23:04
by marktn
Maybe a good wiki is an idea? I see a lot in this post. But don´t know where to start.

send from tapatalk app.