Controlling Toon [HACKED] from Domoticz

For heating/cooling related questions in Domoticz

Moderator: leecollings

Post Reply
ronalddehaan
Posts: 11
Joined: Monday 09 October 2017 10:20
Target OS: Linux
Domoticz version: 2021.1
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ronalddehaan »

Maes wrote: Friday 20 October 2017 9:13 Ahh.. I didn't know. Unfortunately it looks like I have to flash my Toon again. Which I can't do, Marcelr did it for me last time ;)
Is there something wrong with it or do you mean you have to reflash because of the app store?
Maes
Posts: 34
Joined: Tuesday 05 April 2016 20:45
Target OS: -
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Maes »

Because of the app store. Marcelr rooted my toon on 4th of april 2016. A lot has changed since then and the "software" that's loaded on my Toon does not support automatic updates.

So, if I want to use any of this new stuff, the Toon will have to be flashed again to the newest version.

Too much trouble for me. Anyway I'm thinking about changing to the Evohome system next year because I moved to a new house which is a lot bigger than the previous one. I would like to control the temperature per room.
ronalddehaan
Posts: 11
Joined: Monday 09 October 2017 10:20
Target OS: Linux
Domoticz version: 2021.1
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ronalddehaan »

Maes wrote: Friday 20 October 2017 9:23 Because of the app store. Marcelr rooted my toon on 4th of april 2016. A lot has changed since then and the "software" that's loaded on my Toon does not support automatic updates.

So, if I want to use any of this new stuff, the Toon will have to be flashed again to the newest version.
Ah I see, yeah you are probably right :lol:
Maybe MarcelR can help you again or someone in the neighborhood who is handy with these things?
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

I've updated the php script that reads out the production values from the smartmeter (trough Toon) aswell.
This one works with a virtual P1 Meter.

I am still testing it. Seeing as today there is almost no sun and I only have 2 solarpanels. I don't expect to return any power.

Code: Select all

#!/usr/bin/php
<?php

/* Version 1.0 written by Ierlandfan */
/* Version 1.0 modified by DennisD */
/* Version 2.0 rewritten by FunFair */
/* Version 2.1 update by FunFair */
/* 24-10-2017 */

/* 
	Changelog Version 2.2:
	- Corrected Low and Normal tariff. They were reversed.
	
	Changelog Version 2.1:																		
	- Implemented production counters for P1 meter.
	- Removed the compare to previous value, so it will update every minute.

	Changelog Version 2.0:																		
	- Rewrite from version 1.0																	
	- Define IP adresses and idx value at start													
	- Check if Toon value is lower than Domoticz Value. (In case connection is lost with meteradapter, Toon will output wrong values.) */

/* Instructions:
	- Create a virtual P1 meter in Domoticz and write down idx value.
	- Place script in Domoticz folder /home/pi/domoticz/scripts/p1_meter/ or desired folder.
	- Set IP numbers and idx values below.
	- Make sure Curl is installed (sudo apt-get install php-curl).
	- Make sure script is executable (chmod +x filename.php).
	- All echo's are used for debugging.
	- Put script in 'crontab -e' to run every minute. */ 
	  #Example crontab: (*/1 * * * * /home/pi/domoticz/scripts/p1_meter/p1_meter_data_json.php)
	
		
/* Set IP addresses and idx*/
$IPDomoticz = '192.168.0.200:8080';
$IPToon = '192.168.0.11';
$idx = 26;

/* read electricity value from Domoticz */
$json_string = file_get_contents("http://$IPDomoticz/json.htm?type=devices&rid=$idx");
$parsed_json = json_decode($json_string, true);
$parsed_json = $parsed_json['result'][0];
$ElecUsageCounterDomoticz = $parsed_json['Counter']*1000;
$ElecProductionCounterDomoticz = $parsed_json['CounterDeliv']*1000;
echo "Electricity Usage Counter Domoticz = ";
echo $ElecUsageCounterDomoticz;
echo " Wh";
echo "\n";
echo "Electricity Production Counter Domoticz = ";
echo $ElecProductionCounterDomoticz;
echo " Wh";
echo "\n";
echo "\n";

/* start of the total Energy Usage counter import */
$file_string_ElecUsageCounter = file_get_contents("http://$IPToon/hdrv_zwave?action=getDevices.json");
$parsed_json_ElecCounter = json_decode($file_string_ElecUsageCounter, true);

/* start of current Energy Usage import */
$file_string_ElecUsage = file_get_contents("http://$IPToon/happ_pwrusage?action=GetCurrentUsage");
$parsed_json_ElecUsage = json_decode($file_string_ElecUsage, true);

/* start of the total Energy Production counter import */
$file_string_ElecProductionCounter = file_get_contents("http://$IPToon/hdrv_zwave?action=getDevices.json");
$parsed_json_ElecProductionCounter = json_decode($file_string_ElecProductionCounter, true);

/* start of current Energy Production import */
$file_string_ElecProduction = file_get_contents("http://$IPToon/happ_pwrusage?action=GetCurrentUsage");
$parsed_json_ElecProduction = json_decode($file_string_ElecProduction, true);

/* extract counter normal tariff and low tariff and add them together */
$ElecUsageCounterNT = $parsed_json_ElecCounter['dev_3.3']['CurrentElectricityQuantity']; #normal tariff
$ElecUsageCounterLT = $parsed_json_ElecCounter['dev_3.5']['CurrentElectricityQuantity']; #low tariff
$ElecUsageCounterToon = $ElecUsageCounterNT + $ElecUsageCounterLT;
$ElecProductionCounterNT = $parsed_json_ElecProductionCounter['dev_3.4']['CurrentElectricityQuantity']; #normal tariff
$ElecProductionCounterLT = $parsed_json_ElecProductionCounter['dev_3.6']['CurrentElectricityQuantity']; #low tariff
$ElecProductionCounterToon = $ElecProductionCounterNT + $ElecProductionCounterLT;
echo "Electricity Counter Toon Low Tariff = ";
echo $ElecUsageCounterLT;
echo " Wh";
echo "\n";

echo "Electricity Counter Toon Normal Tariff = ";
echo $ElecUsageCounterNT;
echo " Wh";
echo "\n";

echo "Electricity Counter Toon Total = ";
echo $ElecUsageCounterToon;
echo " Wh";
echo "\n";
echo "\n";

echo "Electricity Production Counter Toon Low Tariff = ";
echo $ElecProductionCounterLT;
echo " Wh";
echo "\n";

echo "Electricity Production Counter Toon Normal Tariff = ";
echo $ElecProductionCounterNT;
echo " Wh";
echo "\n";

echo "Electricity Production Counter Toon Total = ";
echo $ElecProductionCounterToon;
echo " Wh";
echo "\n";
echo "\n";

/* extract the current powerusage */
$ElecUsageToon=$parsed_json_ElecUsage['powerUsage']['value'];
echo "Electricity Usage Toon = ";
echo $ElecUsageToon;
echo " Watt";
echo "\n";

/* extract the current powerProduction */
$ElecProductionToon=$parsed_json_ElecProduction['powerProduction']['value'];
echo "Electricity Production Toon = ";
echo $ElecProductionToon;
echo " Watt";
echo "\n";


/* write new value to Domoticz	*/
if ($ElecUsageCounterDomoticz == 0){ #this is for the first run only, when the idx is still empty.
	$WriteInitValue = curl_init("http://$IPDomoticz/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$ElecUsageCounterLT;$ElecUsageCounterNT;$ElecProductionCounterLT;$ElecProductionCounterNT;$ElecUsageToon;$ElecProductionToon;");
		curl_exec($WriteInitValue);
	}
	else if ($ElecUsageCounterToon < $ElecUsageCounterDomoticz){ 
		echo "Toon value incorrect, do nothing \n";
	}
	else if ($ElecUsageCounterToon >= $ElecUsageCounterDomoticz){
		$WriteValue = curl_init("http://$IPDomoticz/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$ElecUsageCounterLT;$ElecUsageCounterNT;$ElecProductionCounterLT;$ElecProductionCounterNT;$ElecUsageToon;$ElecProductionToon;");
		echo "\n";
		echo "Write new value \n";
		curl_exec($WriteValue);
	}
	else {
		echo "Domoticz value incorrect, do nothing \n";
	}
?>

-edit-
Tested it and changed it a bit. Changed the code above and attached new verion as zip. Corrected a huge rror by confusing daytime and nighttime.
corrected the other scripts aswell

-edit2-
corrected some variables for all scripts. See new attached file.
Attachments
Gas_Elec_Values_Hacked_Toon_v22.zip
(5.59 KiB) Downloaded 249 times
Last edited by FunFair on Tuesday 24 October 2017 20:08, edited 5 times in total.
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by bertbigb »

Hi,

I try to make the hacked Toon work with Domoticx work but I get an error and don't know what's wrong

The error is this:
2017-10-22 20:33:00.621 Error: dzVents: Error: An error occured when calling event handler ToonGetInfo
2017-10-22 20:33:00.621 Error: dzVents: Error: ...cz/var/scripts/dzVents/generated_scripts/ToonGetInfo.lua:61: attempt to call field 'round' (a nil value)

Line 61 is this one out of the script:
if domoticz.round(domoticz.devices(ToonTemperatureSensorName).temperature, 1) ~= domoticz.round(currentTemperature, 1) then

The following :

local ToonThermostatSensorName = domoticz.variables('UV_ToonThermostatSensorName').value -- Sensor showing current setpoint:

the user variable UV_ToonTemperatureSensorName is filled in as Toon Temperature and Toon Temperature exist as a virtual Temp(erature) variable.

I hope someone can point me out what is wrong
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

Can you post a screenshot of your "Devices" and "User variables" ?
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by bertbigb »

Hi,

Of course I will.

My variables:
user-variables.jpg
user-variables.jpg (77.55 KiB) Viewed 3835 times
My devices:
devices.jpg
devices.jpg (70.2 KiB) Viewed 3835 times
One other thing I have changed since I work with a synology is:
-- Handle json
--local json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows
--local json = assert(loadfile "/home/maes/domoticz/scripts/lua/JSON.lua")() -- For Linux
local json = assert(loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")() -- For Synology

I hope someone can help me with this one, tried a lot already but haven't found the cause
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

Do you have curl installed?
bertbigb
Posts: 147
Joined: Thursday 13 August 2015 13:36
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by bertbigb »

FunFair wrote: Monday 23 October 2017 19:47 Do you have curl installed?
Yes, curl is installed.

Personally I have the feeling that it is something in the dzVents scripts.
Is there anyone who can confirm to have the dzVentz scripts as available on the first page working?

I say this since with the lua scripts it is working OK, but the dzVentz gives problems.

Hereby my code (only changed the part for Synology) and moved the part what gives an error to the end to check the rest of the script (what is working fine)

It is the part:
if domoticz.round(domoticz.devices(ToonTemperatureSensorName).temperature, 1) ~= domoticz.round(currentTemperature, 1) then
where the nil error occurs

Code: Select all

-- Check the wiki at
-- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
return {
	on = {
		timer = {
			'every minute'
		}
	},
	execute = function(domoticz)
        local ToonThermostatSensorName = domoticz.variables('UV_ToonThermostatSensorName').value -- Sensor showing current setpoint
        local ToonTemperatureSensorName = domoticz.variables('UV_ToonTemperatureSensorName').value -- Sensor showing current room temperature
        local ToonScenesSensorName  = domoticz.variables('UV_ToonScenesSensorName').value -- Sensor showing current program
        local ToonAutoProgramSensorName = domoticz.variables('UV_ToonAutoProgramSensorName').value -- Sensor showing current auto program status
        local ToonProgramInformationSensorName = domoticz.variables('UV_ToonProgramInformationSensorName').value -- Sensor showing displaying program information status
        local ToonIP = domoticz.variables('UV_ToonIP').value
        local DomoticzIP = domoticz.variables('UV_DomoticzIP').value

        -- Handle json
        --local json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
        --local json = assert(loadfile "/home/maes/domoticz/scripts/lua/JSON.lua")()  -- For Linux
        local json = assert(loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")()  -- For Synology
        
        --local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
        local handle = assert(io.popen(string.format('curl http://192.168.3.104/happ_thermstat?action=getThermostatInfo', ToonIP)))
        local ThermostatInfo = handle:read('*all')
        handle:close()
        
        local jsonThermostatInfo = json:decode(ThermostatInfo)
        
        if jsonThermostatInfo == nil then
            return
        end
        
        local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
        local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
        local currentProgramState = tonumber(jsonThermostatInfo.programState)
            if currentProgramState == 0 then currentProgramState = 10 -- No
                elseif currentProgramState == 1 then currentProgramState = 20 -- Yes
                elseif currentProgramState == 2 then currentProgramState = 30 -- Temporary       
            end      
        local currentActiveState = tonumber(jsonThermostatInfo.activeState)
            if currentActiveState == -1 then currentActiveState = 50 -- Manual
                elseif currentActiveState == 0 then currentActiveState = 40 -- Comfort
                elseif currentActiveState == 1 then currentActiveState = 30 -- Home
                elseif currentActiveState == 2 then currentActiveState = 20 -- Sleep
                elseif currentActiveState == 3 then currentActiveState = 10 -- Away
            end
        local currentNextTime = jsonThermostatInfo.nextTime
        local currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
        local currentBoiletSetPoint = jsonThermostatInfo.currentInternalBoilerSetpoint
        ----
        
        
        -- Update the thermostat sensor to current setpoint
        if domoticz.devices(ToonThermostatSensorName).setPoint*100 ~= currentSetpoint*100 then
            domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint)
            domoticz.devices(ToonThermostatSensorName).updateSetPoint(currentSetpoint).silent()
        end
        
        -- Update the toon scene selector sensor to current program state
        if domoticz.devices(ToonScenesSensorName).level ~= currentActiveState then  -- Update toon selector if it has changed
            domoticz.log('Updating Toon Scenes selector to: '..currentActiveState)
            domoticz.devices(ToonScenesSensorName).switchSelector(currentActiveState).silent()
        end
        
        -- Updates the toon auto program switch 
        if domoticz.devices(ToonAutoProgramSensorName).level ~= currentProgramState then -- Update toon auto program selector if it has changed
            domoticz.log('Updating Toon Auto Program selector to: '..currentProgramState)
            domoticz.devices(ToonAutoProgramSensorName).switchSelector(currentProgramState).silent()
        end
        
        -- Updates the toon program information text box
        if currentNextTime == 0 or currentNextSetPoint == 0 then
            ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
        else
            ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
        end
        
        if domoticz.devices(ToonProgramInformationSensorName).text ~= ToonProgramInformationSensorValue then
            domoticz.log('Updating Toon Program Information to: '..ToonProgramInformationSensorValue)
            domoticz.devices(ToonProgramInformationSensorName).updateText(ToonProgramInformationSensorValue)
        end
        
        print("currentTemperature - " .. currentTemperature)
        
        -- Update the temperature sensor to current room temperature
        if domoticz.round(domoticz.devices(ToonTemperatureSensorName).temperature, 1) ~= domoticz.round(currentTemperature, 1) then 
            domoticz.log('Updating the temperature sensor to new value: ' ..currentTemperature)
            domoticz.devices(ToonTemperatureSensorName).updateTemperature(currentTemperature)
        end
        
        
	end
}
Best regards Bert

Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

oh that is quite possible. I remember someone else in this topic also having problems with the new dzVents. For me it's not working either, so I use the LUA aswell.
pascal34
Posts: 2
Joined: Thursday 26 October 2017 8:46
Target OS: Windows
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by pascal34 »

FunFair wrote: Sunday 22 October 2017 9:55 I've updated the php script that reads out the production values from the smartmeter (trough Toon) aswell.
This one works with a virtual P1 Meter.

I am still testing it. Seeing as today there is almost no sun and I only have 2 solarpanels. I don't expect to return any power.

Code: Select all

#!/usr/bin/php
<?php

/* Version 1.0 written by Ierlandfan */
/* Version 1.0 modified by DennisD */
/* Version 2.0 rewritten by FunFair */
/* Version 2.1 update by FunFair */
/* 24-10-2017 */

/* 
	Changelog Version 2.2:
	- Corrected Low and Normal tariff. They were reversed.
	
	Changelog Version 2.1:																		
	- Implemented production counters for P1 meter.
	- Removed the compare to previous value, so it will update every minute.

	Changelog Version 2.0:																		
	- Rewrite from version 1.0																	
	- Define IP adresses and idx value at start													
	- Check if Toon value is lower than Domoticz Value. (In case connection is lost with meteradapter, Toon will output wrong values.) */

/* Instructions:
	- Create a virtual P1 meter in Domoticz and write down idx value.
	- Place script in Domoticz folder /home/pi/domoticz/scripts/p1_meter/ or desired folder.
	- Set IP numbers and idx values below.
	- Make sure Curl is installed (sudo apt-get install php-curl).
	- Make sure script is executable (chmod +x filename.php).
	- All echo's are used for debugging.
	- Put script in 'crontab -e' to run every minute. */ 
	  #Example crontab: (*/1 * * * * /home/pi/domoticz/scripts/p1_meter/p1_meter_data_json.php)
	
		
/* Set IP addresses and idx*/
$IPDomoticz = '192.168.0.200:8080';
$IPToon = '192.168.0.11';
$idx = 26;

/* read electricity value from Domoticz */
$json_string = file_get_contents("http://$IPDomoticz/json.htm?type=devices&rid=$idx");
$parsed_json = json_decode($json_string, true);
$parsed_json = $parsed_json['result'][0];
$ElecUsageCounterDomoticz = $parsed_json['Counter']*1000;
$ElecProductionCounterDomoticz = $parsed_json['CounterDeliv']*1000;
echo "Electricity Usage Counter Domoticz = ";
echo $ElecUsageCounterDomoticz;
echo " Wh";
echo "\n";
echo "Electricity Production Counter Domoticz = ";
echo $ElecProductionCounterDomoticz;
echo " Wh";
echo "\n";
echo "\n";

/* start of the total Energy Usage counter import */
$file_string_ElecUsageCounter = file_get_contents("http://$IPToon/hdrv_zwave?action=getDevices.json");
$parsed_json_ElecCounter = json_decode($file_string_ElecUsageCounter, true);

/* start of current Energy Usage import */
$file_string_ElecUsage = file_get_contents("http://$IPToon/happ_pwrusage?action=GetCurrentUsage");
$parsed_json_ElecUsage = json_decode($file_string_ElecUsage, true);

/* start of the total Energy Production counter import */
$file_string_ElecProductionCounter = file_get_contents("http://$IPToon/hdrv_zwave?action=getDevices.json");
$parsed_json_ElecProductionCounter = json_decode($file_string_ElecProductionCounter, true);

/* start of current Energy Production import */
$file_string_ElecProduction = file_get_contents("http://$IPToon/happ_pwrusage?action=GetCurrentUsage");
$parsed_json_ElecProduction = json_decode($file_string_ElecProduction, true);

/* extract counter normal tariff and low tariff and add them together */
$ElecUsageCounterNT = $parsed_json_ElecCounter['dev_3.3']['CurrentElectricityQuantity']; #normal tariff
$ElecUsageCounterLT = $parsed_json_ElecCounter['dev_3.5']['CurrentElectricityQuantity']; #low tariff
$ElecUsageCounterToon = $ElecUsageCounterNT + $ElecUsageCounterLT;
$ElecProductionCounterNT = $parsed_json_ElecProductionCounter['dev_3.4']['CurrentElectricityQuantity']; #normal tariff
$ElecProductionCounterLT = $parsed_json_ElecProductionCounter['dev_3.6']['CurrentElectricityQuantity']; #low tariff
$ElecProductionCounterToon = $ElecProductionCounterNT + $ElecProductionCounterLT;
echo "Electricity Counter Toon Low Tariff = ";
echo $ElecUsageCounterLT;
echo " Wh";
echo "\n";

echo "Electricity Counter Toon Normal Tariff = ";
echo $ElecUsageCounterNT;
echo " Wh";
echo "\n";

echo "Electricity Counter Toon Total = ";
echo $ElecUsageCounterToon;
echo " Wh";
echo "\n";
echo "\n";

echo "Electricity Production Counter Toon Low Tariff = ";
echo $ElecProductionCounterLT;
echo " Wh";
echo "\n";

echo "Electricity Production Counter Toon Normal Tariff = ";
echo $ElecProductionCounterNT;
echo " Wh";
echo "\n";

echo "Electricity Production Counter Toon Total = ";
echo $ElecProductionCounterToon;
echo " Wh";
echo "\n";
echo "\n";

/* extract the current powerusage */
$ElecUsageToon=$parsed_json_ElecUsage['powerUsage']['value'];
echo "Electricity Usage Toon = ";
echo $ElecUsageToon;
echo " Watt";
echo "\n";

/* extract the current powerProduction */
$ElecProductionToon=$parsed_json_ElecProduction['powerProduction']['value'];
echo "Electricity Production Toon = ";
echo $ElecProductionToon;
echo " Watt";
echo "\n";


/* write new value to Domoticz	*/
if ($ElecUsageCounterDomoticz == 0){ #this is for the first run only, when the idx is still empty.
	$WriteInitValue = curl_init("http://$IPDomoticz/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$ElecUsageCounterLT;$ElecUsageCounterNT;$ElecProductionCounterLT;$ElecProductionCounterNT;$ElecUsageToon;$ElecProductionToon;");
		curl_exec($WriteInitValue);
	}
	else if ($ElecUsageCounterToon < $ElecUsageCounterDomoticz){ 
		echo "Toon value incorrect, do nothing \n";
	}
	else if ($ElecUsageCounterToon >= $ElecUsageCounterDomoticz){
		$WriteValue = curl_init("http://$IPDomoticz/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$ElecUsageCounterLT;$ElecUsageCounterNT;$ElecProductionCounterLT;$ElecProductionCounterNT;$ElecUsageToon;$ElecProductionToon;");
		echo "\n";
		echo "Write new value \n";
		curl_exec($WriteValue);
	}
	else {
		echo "Domoticz value incorrect, do nothing \n";
	}
?>

-edit-
Tested it and changed it a bit. Changed the code above and attached new verion as zip. Corrected a huge rror by confusing daytime and nighttime.
corrected the other scripts aswell

-edit2-
corrected some variables for all scripts. See new attached file.
Hi, I am using this scripts for my energy readings.
But wen I set in Domoticz Setup > Settings in Website Protection a username and Password the scripts stopped working, wen I remove my username and password they are updating again. How can I fix this.
Using Domoticz V3.8153 on a Rasberry Pi 3 B

Thanks, Pascal
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie »

i tried the gas/electra php script but in both i get an error, im running Domoticz on a pi2 and i use a hacked Toon.

Code: Select all

pi@raspberrypi:~/domoticz/scripts/php $ ./electricity_data_json.php
Electricity Counter Domoticz = 0 Wh
Electricity Counter Toon = 0 Wh
Electricity Usage Toon = 413 Watt
PHP Fatal error:  Call to undefined function curl_init() in /home/pi/domoticz/scripts/php/electricity_data_json.php on line 71

and

Code: Select all

pi@raspberrypi:~/domoticz/scripts/php $ ./gas_data_json.php
Gas Value Domoticz = 0 liters
Gas Value Toon = 590.00 liters

PHP Fatal error:  Call to undefined function curl_init() in /home/pi/domoticz/scripts/php/gas_data_json.php on line 55
Can someone point me in the right direction?

======update========

solved by installing the right curl.
1 problem remains, i dont get the electricity counter this remain 0

Code: Select all


pi@raspberrypi:~/domoticz/scripts/php $ ./electricity_data_json.php
Electricity Counter Domoticz = 0 Wh
Electricity Counter Toon = 0 Wh
Electricity Usage Toon = 654 Watt
{
   "status" : "OK",
   "title" : "Update Device"
}
Last edited by gielie on Saturday 11 November 2017 9:12, edited 1 time in total.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
DennisD
Posts: 51
Joined: Friday 18 September 2015 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by DennisD »

Curl doesn't seem installed!

Try:
sudo apt-get install php5-curl
sudo service apache2 restart
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

Check if the dev_x.x are correct in http://192.168.0.11/hdrv_zwave?action=getDevices.json
Change ip to your toon.

Maybe they are different from my Toon?

Look for "elec_delivered_nt" and "elec_delivered_lt"
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

pascal34 wrote: Friday 10 November 2017 10:59
Hi, I am using this scripts for my energy readings.
But wen I set in Domoticz Setup > Settings in Website Protection a username and Password the scripts stopped working, wen I remove my username and password they are updating again. How can I fix this.
Using Domoticz V3.8153 on a Rasberry Pi 3 B

Thanks, Pascal
https://www.domoticz.com/wiki/Domoticz_ ... 27s#Format
Add this to the $IPDomoticz setting.

So $IPDomoticz = 'username:password@domoticz-ip:port';
pascal34
Posts: 2
Joined: Thursday 26 October 2017 8:46
Target OS: Windows
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by pascal34 »

FunFair wrote: Saturday 11 November 2017 9:26
pascal34 wrote: Friday 10 November 2017 10:59
Hi, I am using this scripts for my energy readings.
But wen I set in Domoticz Setup > Settings in Website Protection a username and Password the scripts stopped working, wen I remove my username and password they are updating again. How can I fix this.
Using Domoticz V3.8153 on a Rasberry Pi 3 B

Thanks, Pascal
https://www.domoticz.com/wiki/Domoticz_ ... 27s#Format
Add this to the $IPDomoticz setting.

So $IPDomoticz = 'username:password@domoticz-ip:port';
Yes thats works

Thanks, FunFair
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie »

FunFair wrote: Saturday 11 November 2017 9:22 Check if the dev_x.x are correct in http://192.168.0.11/hdrv_zwave?action=getDevices.json
Change ip to your toon.

Maybe they are different from my Toon?

Look for "elec_delivered_nt" and "elec_delivered_lt"
This is my output

Code: Select all

{ 
"dev_settings_device":{"uuid":"eneco-001-003065:hdrv_zwave_722E1463E52", "name":"settings_device", "internalAddress":"settings_device", "type":"settings_device", "supportsCrc":"0", "location":"(null)"},
"dev_3":{"uuid":"eneco-001-003065:hdrv_zwave_72262C23F3F", "name":"HAE_METER_v2", "internalAddress":"3", "type":"HAE_METER_v2", "supportsCrc":"1", "ccList":"22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "supportedCC":"22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "IsConnected":"1", "HealthValue":"10", "DeviceName":"", "location":"(null)"},
"dev_3.1":{"uuid":"eneco-001-003065:hdrv_zwave_72227F83F45", "name":"HAE_METER_v2_1", "internalAddress":"3.1", "type":"gas", "supportsCrc":"0", "ccList":"3c 3d 3e 72 86", "supportedCC":"3c 3d 3e 72 86", "CurrentGasFlow":"0.00", "CurrentGasQuantity":"1990.00", "location":"(null)"},
"dev_3.2":{"uuid":"eneco-001-003065:hdrv_zwave_722E9E83F45", "name":"HAE_METER_v2_2", "internalAddress":"3.2", "type":"elec", "supportsCrc":"0", "CurrentElectricityFlow":"3682.00", "CurrentElectricityQuantity":"9640.00", "location":"(null)"},
"dev_3.3":{"uuid":"eneco-001-003065:hdrv_zwave_722438D3F45", "name":"HAE_METER_v2_3", "internalAddress":"3.3", "type":"elec_delivered_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.4":{"uuid":"eneco-001-003065:hdrv_zwave_722255A3F45", "name":"HAE_METER_v2_4", "internalAddress":"3.4", "type":"elec_received_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.5":{"uuid":"eneco-001-003065:hdrv_zwave_72272633F45", "name":"HAE_METER_v2_5", "internalAddress":"3.5", "type":"elec_delivered_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.6":{"uuid":"eneco-001-003065:hdrv_zwave_722D79F3F45", "name":"HAE_METER_v2_6", "internalAddress":"3.6", "type":"elec_received_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}
}
does this make sense?
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

gielie wrote: Sunday 12 November 2017 16:43
FunFair wrote: Saturday 11 November 2017 9:22 Check if the dev_x.x are correct in http://192.168.0.11/hdrv_zwave?action=getDevices.json
Change ip to your toon.

Maybe they are different from my Toon?

Look for "elec_delivered_nt" and "elec_delivered_lt"
This is my output

Code: Select all

{ 
"dev_settings_device":{"uuid":"eneco-001-003065:hdrv_zwave_722E1463E52", "name":"settings_device", "internalAddress":"settings_device", "type":"settings_device", "supportsCrc":"0", "location":"(null)"},
"dev_3":{"uuid":"eneco-001-003065:hdrv_zwave_72262C23F3F", "name":"HAE_METER_v2", "internalAddress":"3", "type":"HAE_METER_v2", "supportsCrc":"1", "ccList":"22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "supportedCC":"22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "IsConnected":"1", "HealthValue":"10", "DeviceName":"", "location":"(null)"},
"dev_3.1":{"uuid":"eneco-001-003065:hdrv_zwave_72227F83F45", "name":"HAE_METER_v2_1", "internalAddress":"3.1", "type":"gas", "supportsCrc":"0", "ccList":"3c 3d 3e 72 86", "supportedCC":"3c 3d 3e 72 86", "CurrentGasFlow":"0.00", "CurrentGasQuantity":"1990.00", "location":"(null)"},
"dev_3.2":{"uuid":"eneco-001-003065:hdrv_zwave_722E9E83F45", "name":"HAE_METER_v2_2", "internalAddress":"3.2", "type":"elec", "supportsCrc":"0", "CurrentElectricityFlow":"3682.00", "CurrentElectricityQuantity":"9640.00", "location":"(null)"},
"dev_3.3":{"uuid":"eneco-001-003065:hdrv_zwave_722438D3F45", "name":"HAE_METER_v2_3", "internalAddress":"3.3", "type":"elec_delivered_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.4":{"uuid":"eneco-001-003065:hdrv_zwave_722255A3F45", "name":"HAE_METER_v2_4", "internalAddress":"3.4", "type":"elec_received_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.5":{"uuid":"eneco-001-003065:hdrv_zwave_72272633F45", "name":"HAE_METER_v2_5", "internalAddress":"3.5", "type":"elec_delivered_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.6":{"uuid":"eneco-001-003065:hdrv_zwave_722D79F3F45", "name":"HAE_METER_v2_6", "internalAddress":"3.6", "type":"elec_received_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}
}
does this make sense?
Do you have a smartmeter?
If not please check the currentgas and currentelectricity quantity if they are the same as on your toon display.
If so the script needs some changes to read out the correct values.
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie »

FunFair wrote: Sunday 12 November 2017 18:31
gielie wrote: Sunday 12 November 2017 16:43
FunFair wrote: Saturday 11 November 2017 9:22 Check if the dev_x.x are correct in http://192.168.0.11/hdrv_zwave?action=getDevices.json
Change ip to your toon.

Maybe they are different from my Toon?

Look for "elec_delivered_nt" and "elec_delivered_lt"
This is my output

Code: Select all

{ 
"dev_settings_device":{"uuid":"eneco-001-003065:hdrv_zwave_722E1463E52", "name":"settings_device", "internalAddress":"settings_device", "type":"settings_device", "supportsCrc":"0", "location":"(null)"},
"dev_3":{"uuid":"eneco-001-003065:hdrv_zwave_72262C23F3F", "name":"HAE_METER_v2", "internalAddress":"3", "type":"HAE_METER_v2", "supportsCrc":"1", "ccList":"22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "supportedCC":"22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "IsConnected":"1", "HealthValue":"10", "DeviceName":"", "location":"(null)"},
"dev_3.1":{"uuid":"eneco-001-003065:hdrv_zwave_72227F83F45", "name":"HAE_METER_v2_1", "internalAddress":"3.1", "type":"gas", "supportsCrc":"0", "ccList":"3c 3d 3e 72 86", "supportedCC":"3c 3d 3e 72 86", "CurrentGasFlow":"0.00", "CurrentGasQuantity":"1990.00", "location":"(null)"},
"dev_3.2":{"uuid":"eneco-001-003065:hdrv_zwave_722E9E83F45", "name":"HAE_METER_v2_2", "internalAddress":"3.2", "type":"elec", "supportsCrc":"0", "CurrentElectricityFlow":"3682.00", "CurrentElectricityQuantity":"9640.00", "location":"(null)"},
"dev_3.3":{"uuid":"eneco-001-003065:hdrv_zwave_722438D3F45", "name":"HAE_METER_v2_3", "internalAddress":"3.3", "type":"elec_delivered_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.4":{"uuid":"eneco-001-003065:hdrv_zwave_722255A3F45", "name":"HAE_METER_v2_4", "internalAddress":"3.4", "type":"elec_received_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.5":{"uuid":"eneco-001-003065:hdrv_zwave_72272633F45", "name":"HAE_METER_v2_5", "internalAddress":"3.5", "type":"elec_delivered_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.6":{"uuid":"eneco-001-003065:hdrv_zwave_722D79F3F45", "name":"HAE_METER_v2_6", "internalAddress":"3.6", "type":"elec_received_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}
}
does this make sense?
Do you have a smartmeter?
If not please check the currentgas and currentelectricity quantity if they are the same as on your toon display.
If so the script needs some changes to read out the correct values.
I don’t have a smart meter, so I figured out I have to change a lot in the script, I will take a shot to change this or does someone here allready have this script ready?
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

Not that much, just change the parser to read the value from the correct dev_x and do some editing to the calculations. If you can wait a few days I'll change it for elec and gas aswell.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests