Page 1 of 1

Import Electric data to domoticz electric(instant+counter)

Posted: Sunday 12 February 2023 9:27
by naeblizz
Hi . I am trying to import sensor data, electricity reading from node red to domoticz. Right now I have 2 dummy sensors general purpose which recives mqtt data from node red to display instant energy consumption and energy counter . This works fine, my problem now is that I am trying to merge those 2 values to 1 dummy sensor "electric(instant+counter)" . I can't seem to get the mqtt syntax right because I get no value on the new sensor when trying to send data. This is what I send to domoticz/in from node red with my general purpose sensor :
{ "idx" : 5041, "nvalue" : {{payload}}, "svalue" : "{{payload}}" }
Im trying to send the same to the electric dummy sensor but I get no value on that one. Anyone knew what I am doing wrong ?

//Mikael

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Sunday 12 February 2023 9:50
by naeblizz
I got it working . tnx anyway

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Wednesday 01 March 2023 18:23
by JustDude
I just had the same question,,, looking for the right value to store the value from Node-red.
I tried svalue, usage, consumed. Nothing works as I would expect.
Is there a datamodel or approach on where to find the correct way?

By the way: Would be nice if you know the solution to let (me) us and other readers know 8-)

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Wednesday 01 March 2023 18:35
by waltervl
There is a node-red subforum here : https://domoticz.com/forum/viewforum.php?f=81

The mqtt message should have the right mqtt format. Are you already able to update the sensor by sending an mqtt message manual?
See wiki https://www.domoticz.com/wiki/MQTT#MQTT_to_Domoticz

Edit: Electric

The electric sensor will show the current usage of electricity in Watt and the cumulative usage in kWh. You can add digits after the decimal if needed.

Code: Select all

{"command":"udevice", "idx":1234, "svalue":"us;cu"}
where us is usage in Watt and cu is cumulative usage in Wh (even though it is displayed in kWh)

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 02 March 2023 21:42
by JustDude
Thanks that helped. Found the Node-red subforum also.

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 18:37
by averter
Hi,

I am trying to do something similar. I've created an instantaneous electric virtual device and want to replace it with an electric (instant + counter) type, but the "instant + counter" device is not listed in the new device drop down menu from the "instantaneous" device. Is there any simple workaround? Thank you in advance.

Averter

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 18:53
by FireWizard
Hello @averter,

You said:
I've created an instantaneous electric virtual device
I have no idea where and what you have created, being "an instantaneous electric virtual device".
Can you give more details?

I think, that you should create in "Hardware" a "Dummy (Does nothing, use for virtual switches only)".
After that you click "Create Virtual Sensors" and select "Electric (Instant + Counter)".

I think that is what you need.

Regards

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 20:25
by averter
Hello @FireWizard,

Thanks and apologies for not being clear. I have one dummy hardware device and have created a virtual sensor of the type "usage (electric)": this is what I mean by instantaneous electric virtual device. It works fine, but it doesn't include an energy counter in kWh, only the kW instantaneous reading, hence why I would like to transfer its log to another virtual sensor of the type "electric (instant + counter)".

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 22:12
by willemd
Is the kWh device set to "computed" or "from device" (using the edit button) ?
If set to computed, then domoticz will calculate the energy from the instantaneous values.

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 22:19
by FireWizard
Hi @averter,

Sorry, that I did not understand your own naming of a virtual "Usage" sensor.
I have one dummy hardware device and have created a virtual sensor of the type "usage (electric)": this is what I mean by instantaneous electric virtual device. It works fine, but it doesn't include an energy counter in kWh, only the kW instantaneous reading
A virtual sensor of the type "Usage" will show you the actual usage in Watt and not the Consumed or Produced Energy.
Therefore you need a sensor of the type: "Electric (Instant + Counter)". but you have to upload also the cumulative usage in Wh.

But, as far as I know, to replace an old sensor for a new one, both have to be of the same type. However this is not the case, so I cannot guarantee any success.

Regards

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 23:13
by averter
willemd wrote: Thursday 17 August 2023 22:12 Is the kWh device set to "computed" or "from device" (using the edit button) ?
If set to computed, then domoticz will calculate the energy from the instantaneous values.
Thanks for letting me know about that option, but my question sort of remains the same. How can I transfer all the instantaneous values from the "usage (electric)" device to the new "electric (instant + counter)" device? Thanks

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 23:16
by averter
FireWizard wrote: Thursday 17 August 2023 22:19 Hi @averter,

Sorry, that I did not understand your own naming of a virtual "Usage" sensor.
I have one dummy hardware device and have created a virtual sensor of the type "usage (electric)": this is what I mean by instantaneous electric virtual device. It works fine, but it doesn't include an energy counter in kWh, only the kW instantaneous reading
A virtual sensor of the type "Usage" will show you the actual usage in Watt and not the Consumed or Produced Energy.
Therefore you need a sensor of the type: "Electric (Instant + Counter)". but you have to upload also the cumulative usage in Wh.

But, as far as I know, to replace an old sensor for a new one, both have to be of the same type. However this is not the case, so I cannot guarantee any success.

Regards
According to the previous reply from willemd it should be possible to calculate the cumulative usages by setting the "computed" instead of "from device" option in the Electric (Instant + Counter)" device, which would sort of make these two sensors equivalent?

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Thursday 17 August 2023 23:25
by FireWizard
@averter,

You can try, but I never did that.

What @willemd said is correct, but he did not say, that you can replace two different type of sensors with each other.

Regards

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Friday 18 August 2023 22:11
by willemd
Indeed, I don't know about transferring data between sensors. I would look into the database see which tables are used for the various sensors, how the structure is and then use sqlite to do a transfer (after first making a backup). Not an easy answer. Maybe there are other options.

Re: Import Electric data to domoticz electric(instant+counter)

Posted: Friday 18 August 2023 22:35
by averter
willemd wrote: Friday 18 August 2023 22:11 Indeed, I don't know about transferring data between sensors. I would look into the database see which tables are used for the various sensors, how the structure is and then use sqlite to do a transfer (after first making a backup). Not an easy answer. Maybe there are other options.
Yes, sqlite is probably my best bet. I'll give it a go after my next backup. Thanks both! ;)