Page 1 of 1

JSON API - Create device with EnergyMeterMode and external Id

Posted: Friday 21 June 2019 19:54
by ghulleman
Hi All,

Regarding the Create device option of the JSON API (https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s)

Is it somehow possible to set:
- An externe device Id (preferable one that can be used to udevice/update the measurement from external).
- Set the 'EnergyMeterMode' to computed for the "Electricity (instant and counter)" device upon create / update if afterwards?

Reason is that I am trying to integrate plugwise circles with this system anno 2019. Yes, I am aware of the other post (https://www.domoticz.com/forum/viewtopi ... =14&t=7420) but I am creating/modifying the node-red / MQTT solution for a standard installation. The plugwise circles have their own ids (7 chars). Also, I want domoticz to calculate the energy used based on the power measurements and the sensors to be created automatically.

Gerrit

Re: JSON API - Create device with EnergyMeterMode and external Id

Posted: Tuesday 08 February 2022 19:58
by pjwschram
Hi,

I've been struggling with the exact same thing. I have a Node-Red script that creates the Device for the plugwise circle. This is done however with an DeviceID (I don't mean the IDX) that has been chosen by Domoticz. Then I want to find the device in the next update of the device, so I need so sort of reference to the created device. It seems only the name works.

I tried updating the Description, EnergyMeterMode and related items, but it doesn't seem to work. I used this JSON, which is used by the UI of Domoticz, but when running the http call from the browser it will not adjust the Description or the EnergyMeterMode.

http://192.168.178.8:8080/json.htm?type ... 4567_power[/b]&switchtype=0&EnergyMeterMode=1&customimage=0&used=true

Does anyone know if it is possible to update the setting for DeviceID, Description and/or EnergyMeterMode?

Re: JSON API - Create device with EnergyMeterMode and external Id

Posted: Wednesday 09 February 2022 0:14
by waltervl
I tested it with one of my test devices and I could change the EnergyMeterMode setting 1 (computed) 0 (from device) and description.
Be aware that you have to refresh the Utility page (F5) to see the change!
I do not think it is possible to change the deviceID

Code: Select all

https://127.0.0.1/json.htm?type=setused&idx=85&name=Omnik%20-%20Inverter%20(kWh)&description=Test%20Description&switchtype=0&EnergyMeterMode=1&customimage=0&used=true

Re: JSON API - Create device with EnergyMeterMode and external Id

Posted: Wednesday 09 February 2022 9:03
by pjwschram
Hmmm, refresh first. That makes sense. Whoopsie, that would be kinda dumb not to have tried that. Will try it out, that would make life much easier.

Update: Indeed it works for both the description and the EnergyMeterMode. So I can use the description field to contain the mac-address of the Plugwise Circle and use that to find the IDX of the device in Node-Red. The user can then rename the device to whatever he wants and still keep the link between Plugwise and Domoticz alive.

Although a way to update/adjust the Device-ID would be great, because that would be the proper way to align the Plugwise configuration and Domoticz properly.

Re: JSON API - Create device with EnergyMeterMode and external Id

Posted: Tuesday 15 February 2022 14:59
by waltervl
There are 2 ways to make a proper hardware integration that can handle this: C++ https://www.domoticz.com/wiki/Developin ... are_plugin or Python Plugin Framework https://www.domoticz.com/wiki/Developin ... hon_plugin
If the hardware supports MQTT Autodiscover it is also possible to use that.