Page 1 of 1

How to send Float values to Domoticz instead of Integers ?

Posted: Saturday 10 February 2018 14:24
by aerno
I'm coding an SDM630 smart meter plugin for energy usage and return for Domoticz at the moment. See attached screenshot.

It is working fine, except that i can only update Integer values instead of Floats.

For updating I use this piece of code.

Code snippet:

row = line.split('\t')

# Watts 1
s="%.1d; %d" % (float(row[7]), 0)
Devices[7].Update(nValue=int(float(row[7])), sValue=s)

'row' contains the fields of a TAB separated ASCII output record from the SDM630 meter.

I have 2 questions:

- I tried sending nValue=float(row[7]). That gives me a type error. How do I update a float value using a float ?

- How do I set the SubTypeName of the Current meter ? I used TypeName 'Current/Ampere'. It currently shows up as a 'CM113/ElectriSave', which I don't have.

Ps. Forgive me my high energy usage ;-) At the moment we're heating our Swedish house directly on electricity using a 2 phase heater. Here in Sweden one pays alot extra to the electricity network company if you're a netto producer over the year. So we have to burn our 500kWh PV overproduction of last summer :roll: Using roughly 60kWh a day it will be done in about 8 days 8-)
sdm630.png
sdm630.png (146.78 KiB) Viewed 1168 times

Re: How to send Float values to Domoticz instead of Integers ?

Posted: Thursday 01 March 2018 10:51
by Barberousse
aerno wrote: Saturday 10 February 2018 14:24 Devices[7].Update(nValue=int(float(row[7])), sValue=s)

- I tried sending nValue=float(row[7]). That gives me a type error. How do I update a float value using a float ?
nValue accepts integers only, you can't pass float with it. Usually, you pass float using sValue, but it is really up to the device type. You should try virtual devices and check which type is using nValue, which gets its value from sValue, and use the correct device type from your plugin.

Re: How to send Float values to Domoticz instead of Integers ?

Posted: Thursday 11 October 2018 13:49
by aerno
Thanx. Currently still on integer values only. Floats would be nicer.

Re: How to send Float values to Domoticz instead of Integers ?

Posted: Friday 12 October 2018 3:27
by Dnpwwo
@aerno,

Have a look at https://github.com/dnpwwo/Domoticz-RAVE ... /plugin.py which writes to a couple of power consumption devices.

For historical reasons not all the Domoticz devices handle data the same way and the Python Framework has not attempted to fix it, it just exposes the Devices as they are.

I looked at these devices a long time ago and this code:

Code: Select all

Devices[2].Update(nValue=0, sValue=sFloat.replace('.',''))
worked for me :o . From your extract below you might try something like:

Code: Select all

Devices[7].Update(nValue=0, sValue=str(float(row[7])))