Page 1 of 1
Energy CM119/CM160 - what data to provide?
Posted: Tuesday 17 December 2013 4:55
by andriej
I've made myself an API between my own counter (with eeprom, it reads current Watt usage and also is relevant of the counter visible in front).
My API from MEGA is uploading the value of the meter to the Domoticz, but I don't think that values are ok.
Currently it gets: ex. 400W and 1072.3178 kWh (total usage).
But in Domoticz i only see 1.072 for CM119/CM160 sensor.
What data should I provide then?
Wouldn't it be better to let users customize data sources a little?
ATM I have to multiply everything by 1000 to see the difference.
-- EDIT:
Okay, I can answer myself once again on this forum...

The problem was that I was sending xxxx.yyyy value multiplied by 1000, so it was received as: xxxxxx.yy00.
I've managed to cut decimal places for 2 only and now it works:
Regards!
Re: Energy CM119/CM160 - what data to provide?
Posted: Tuesday 17 December 2013 9:49
by andriej
Unfortunately, Domoticz count's my presentation of data as a super-high usage, from last hour in example (51210 Watt).
So yeah, the question is still open - how shall I pass the data to domoticz and what sould it be...
Re: Energy CM119/CM160 - what data to provide?
Posted: Tuesday 17 December 2013 12:25
by Peter112
I do not know if the owl CM180 does the same, but her is some information
http://www.domoticz.com/forum/viewtopic ... 4543#p4543
i have changed the "hardware" en it is displayed as rfxmeter. Until domoticz provide "generic" switches, counters and meters. for the users who are sending data on a different way.
Re: Energy CM119/CM160 - what data to provide?
Posted: Tuesday 17 December 2013 20:41
by andriej
Ok, but how can I pass it thru JSON?
At the moment I don't have any clue...
Re: Energy CM119/CM160 - what data to provide?
Posted: Sunday 29 December 2013 3:06
by kylegordon
If you already have a 'device' that you want to update, head into Setup -> Devices, and find your CM119/CM160/CM180 device in the list. The third column should contain the index number of the device - that's the unique number associated with your device.
You can then craft a URL to call with a new value. So for example if your device is index 39, and you wish to pass the value 121912, you can GET this URL with whatever HTTP library you wish. There's no need for JSON or any data payload in this instance, as you can just pass the value in the URL.
http://domoticzserver.example.com:8080/ ... lue=121912
Re: Energy CM119/CM160 - what data to provide?
Posted: Sunday 11 January 2015 10:36
by BazsoDombiAndras
Hi!
I'm also trying to send the data from a solar panel to my Domoticz virtual sensors. I've created 3 virtual sensors, for Volts, Amps and Watts.
Unfortunately I only see the values for Voltage in Domoticz. The values for Amps shows up in the wrong place and the watt meter always shows 0.
Am I sending the data to the Amps and Watts virtual sensors in the wrong format? Maybe they need more than just one value?
Here's how I send the values to the virtual sensors:
Code: Select all
#!/bin/bash
basedir=$(dirname $0)
sVals=`python $basedir//getAvgVals.py | tr '[ ]' ':'`
IFS=':'
array=( $sVals )
pv_volts="${array[1]}"
pv_amps="${array[3]}"
pv_watts="${array[5]}"
domoticz_host="192.168.1.21:8080"
domoticz_vdevice_idx_pv_volts=44 #Unique Domoticz virtual device index for the solar panel volts
domoticz_vdevice_idx_pv_amps=45 #Unique Domoticz virtual device index for the solar panel amps
domoticz_vdevice_idx_pv_watts=46 #Unique Domoticz virtual device index for the solar panel watts
#Send to Domoticz
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx_pv_volts&nvalue=0&svalue=$pv_volts;1"
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx_pv_amps&nvalue=0&svalue=$pv_amps;1"
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx_pv_watts&nvalue=0&svalue=$pv_watts;1"
Re: Energy CM119/CM160 - what data to provide?
Posted: Sunday 11 January 2015 11:32
by BazsoDombiAndras
Ok, it seems that I have figured out the format for the watts meter (CM119/CM160): it needs 3 values, out of which the first one is the watts value, God onloy knows what the other two are, so I send 0 for the other two, like this:
Code: Select all
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx_pv_watts&nvalue=0&svalue=$pv_watts,0,0;3"
I still can't figure out what to send to the amps meter (CM113)...
Re: Energy CM119/CM160 - what data to provide?
Posted: Tuesday 13 January 2015 9:52
by BazsoDombiAndras
After more investigation and experimenting, the correct way to send data to the watts meter (CM119/CM160) is this: 2 values need to be sent separated by a a semicolon: power (in watts) and energy (in watt-hours, not kilo-watt-hours):
Code: Select all
domoticz_vdevice_idx=INDEX_OF_THE_WATTS_METER_VIRTUAL_DEVICE_IN_DOMOTICZ #change to your value
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx&nvalue=0&svalue=$watts;$watthours"
The two values are needed because this virtual watts meter is a "dump" one in the sense that it won't calculate kilo-watt-hours from watts. You need to calculate it on the application side and send it to the watts meter.
I still cannot find any info about how to feed data into the CM113 (amps meter).
Re: Energy CM119/CM160 - what data to provide?
Posted: Thursday 15 January 2015 9:20
by BazsoDombiAndras
I managed to figure out based on the Domoticz source code in WebServer.cpp (look for text: CM113) that the CM113 needs 3 values to be sent separated by semicolons. These 3 values represent the 3 measured current values or a 3-phase CM113 amp-meter.
So the correct script to upload voltage, current, power and energy values to Domoticz (for example from a photo voltaic solar panel) looks like this:
Code: Select all
#!/bin/bash
pv_volts=#Get the voltage value here
pv_amps=#Get the current value here
pv_watts=#Get the power value here
pv_wh=#Get the total energy value here
domoticz_host="192.168.1.21:8080" #The IP address and port number of your Domoticz web server
domoticz_vdevice_idx_pv_volts=44 #Unique Domoticz virtual volt-meter device index
domoticz_vdevice_idx_pv_amps=45 #Unique Domoticz virtual amp-meter (CM113) device index
domoticz_vdevice_idx_pv_watts=46 #Unique Domoticz virtual watt-meter (CM119/CM160) device index
#Send to Domoticz
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx_pv_volts&nvalue=0&svalue=$pv_volts"
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx_pv_amps&nvalue=0&svalue=$pv_amps;0.0;0.0"
curl -s -i -H "Accept: application/json" \
"http://$domoticz_host/json.htm?type=command¶m=udevice&idx=$domoticz_vdevice_idx_pv_watts&nvalue=0&svalue=$pv_watts;$pv_wh"
echo
echo "Sent values: V=$pv_volts, A=$pv_amps, W=$pv_watts, Wh=$pv_wh"
Re: Energy CM119/CM160 - what data to provide?
Posted: Saturday 16 January 2016 21:57
by Toulon7559
The script by BazsoDombiAndras seems quite useful for my application:
upload by a Python-script to Domoticz of info measured by a kWh-meter DDS238-1ZN. The info-set selected from that kWh-meter also comprises Power, Energy, Voltage and Current.
After tuning the script-lines to the applicable settings for my configuration I ran a test with the latest version of Domoticz and related Python.
The RS485-interface for the kWh-meter is located at the Raspberry which also holds Domoticz, and therefore I inserted IP-adress = 127.0.0.1 (for localhost) with port = 8080 with the IDXes obviously unique for my configuration of Domoticz.
Got an error-report.

- Errorreport on script
- Screenshot160116.JPG (13.21 KiB) Viewed 3183 times
Question: Why that error-report?
Or is some adaptation required to run these curl-lines as part of a Python-script?