Energy CM119/CM160 - what data to provide?

Moderator: leecollings

Post Reply
andriej
Posts: 46
Joined: Tuesday 10 December 2013 22:27
Target OS: Linux
Domoticz version: beta
Contact:

Energy CM119/CM160 - what data to provide?

Post 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!
Attachments
properly shown
properly shown
electr.jpg (27.47 KiB) Viewed 4774 times
Own counter
Own counter
IMG_20131216_231959.jpg (94.16 KiB) Viewed 4776 times
Orange Pi (@ Debian) / MySensors Serial / GPIO / Custom Serial 433 MHz Transmitter (for plug switches and livolo wall switches) / JSON&Bash API scripts
andriej
Posts: 46
Joined: Tuesday 10 December 2013 22:27
Target OS: Linux
Domoticz version: beta
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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...
Orange Pi (@ Debian) / MySensors Serial / GPIO / Custom Serial 433 MHz Transmitter (for plug switches and livolo wall switches) / JSON&Bash API scripts
Peter112
Posts: 16
Joined: Tuesday 15 October 2013 14:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Uithuizen,Groningen,The Netherlands
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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.
RaspberryPI domoticz, test server Intel Atom 230 dual core @1,6 GhzW7-32bit domoticz Test,RFXtrx433 USB, Kaku ,OWL
andriej
Posts: 46
Joined: Tuesday 10 December 2013 22:27
Target OS: Linux
Domoticz version: beta
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post by andriej »

Ok, but how can I pass it thru JSON?
At the moment I don't have any clue...
Orange Pi (@ Debian) / MySensors Serial / GPIO / Custom Serial 433 MHz Transmitter (for plug switches and livolo wall switches) / JSON&Bash API scripts
kylegordon
Posts: 26
Joined: Thursday 31 October 2013 23:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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
1 x HP DL380 & KVM
1 x RPI
1 x RFXtrx433 V78
11 x LWRF Switches
1 x LIFX
2 x Echo Dots
6 x Byron PIRs
2 x Nexa PIRs
2 x Kodi
2 x ESP8266 MQTT
1 x GPIO/MQTT PIR
1 x GPIO(PWM)/MQTT LEDs
1 x GPIO(SPI)/MQTT LPD6803 LEDs
Lots of Node-Red glue
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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.

Image

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&param=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&param=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&param=udevice&idx=$domoticz_vdevice_idx_pv_watts&nvalue=0&svalue=$pv_watts;1"
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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&param=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)...
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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&param=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).
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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&param=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&param=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&param=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"
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Energy CM119/CM160 - what data to provide?

Post 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
Errorreport on script
Screenshot160116.JPG (13.21 KiB) Viewed 3186 times
Question: Why that error-report?
Or is some adaptation required to run these curl-lines as part of a Python-script?
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest