FlyingDomotic / domoticz-mqttmapper-plugin

Domoticz plugin to map MQTT topics to devices/Associe MQTT topics et Domoticz dispositifs
GNU General Public License v3.0
22 stars 6 forks source link

Use of kw #19

Open calou033 opened 3 weeks ago

calou033 commented 3 weeks ago

Hi, I continued to try using your nice plugin to display my PV value. I fix the json syntax but still dealing with kw/kwh I get value from mosquitto: "solpiplog/pip/acoutw = 0566" for example that mean power AC used 566W I chose switch 249,29,0 (kw/kwh) and I want domoticz to calculate the energy consumed by time I try the following but not succesful no data load "Charge": { "topic": "solpiplog/pip/acoutw", "type": "243", "subtype": "29", "options": {"EnergyMeterMode": "1"}, "mapping": {"item": ""} }

Here after are the log 2024-10-11 20:07:25.215 MQTT: Setting MQTT - Charge to 460/460 2024-10-11 20:07:25.216 (MQTT - Charge) Updating device from 456:'' to have values 460:'460'.

Can you help me ? Merci Pascal

FlyingDomotic commented 3 weeks ago

This is matter of sValue content format to send to Domoticz. To help, you can use findDomoticzTypes.py as follow:

Specify either number ('123'), hexadecimal number ('0xf3'), string ('general') or regex ('.*'), separated by ','
Enter ',,.*' to display everything
Type, subType, switchType: 243,29
  Type 243: General
    Subtype 29: Kwh
        sValue: name: instant, unit: W, dataType: floating point number, digits: 3
        sValue2: name: counter, unit: kWh, dataType: floating point number, digits: 3

It gives, among others, sValue format to send to Domoticz. Here, there's 2 items in sValue. First value is instant power (in W), second is total kWh. Having a look at https://www.domoticz.com/wiki/Developing_a_Python_plugin, for type 243, subtype 29, gives:

Electric (Instant+Counter)
nValue should be zero

sValue are two numbers separated by semicolon like "123;123456" The first number is the actual power in Watt, the second number is actual energy in kWh. When the option "EnergyMeterMode" is set to "Calculated", the second value is ignored
Optional argument Options can set the EnergyMeterMode.
Use Options={'EnergyMeterMode': '1' } to set energyMeterMode to "Calculated". Default is "From Device"

When creating the device, set Switchtype=4 to get a device exporting energy (instead of importing) 

Try with:

"mapping": {"item": "~*;0"}

It will insert topic value followed by 0, the last being ignored.

calou033 commented 3 weeks ago

Hi, I tried your suggestion but failed

In status log: 2024-10-12 10:25:13.252 Status: Warning: Expecting svalue with at least 1 elements separated by semicolon, 0 elements received (""), notification not sent (Hardware: 15 - MQTT mapper, ID: solpiplog/pip/acoutw, Unit: 8, Type: F3 - General, SubType: 29 - kWh)

In error log 2024-10-12 10:14:48.674 Error: MQTT mapper: Can't find >0< in >0485<

My problem is to understand the relation ship in between the domoticz definition and the setup to acheive in your json file.

Bonne journée Pascal

FlyingDomotic commented 3 weeks ago

My mistake! Try with: "mapping": {"item": "~*;~0"}

calou033 commented 1 week ago

Hi, I was away for a while

I applied your suggestion, no more error but still no data :(

2024-10-25 17:48:00.300 MQTT mapper: onMQTTPublish found solpiplog/pip/acoutw, Device 'MQTT mapper - Charge', message '0327' 2024-10-25 17:48:00.300 MQTT mapper: Setting MQTT mapper - Charge to >327;0< 2024-10-25 17:48:00.301 (MQTT mapper - Charge) Updating device from 0:'' to have values 0:'327;0'.

JSON "Charge": { "topic": "solpiplog/pip/acoutw", "type": "243", "subtype": "29", "switchtype": "0", "options": {"EnergyMeterMode": "1"}, "mapping": {"item": "~*;~0"}

No more idea ? Thank's Pascal

FlyingDomotic commented 1 week ago

Log display: 2024-10-25 17:48:00.301 (MQTT mapper - Charge) Updating device from 0:'' to have values 0:'327;0'.

This means that Domoticz changed the device value to nValue=0 and sValue="327;0", which seems a good idea.

Could please check device value in "Setup" > "Device" ?

calou033 commented 1 week ago

image

calou033 commented 1 week ago

image

calou033 commented 1 week ago

image

FlyingDomotic commented 1 week ago

Sorry for the delay, I was far from my PC this week-end... I made a change as I read that nValue should be zero for type 243/sub type 29 (and some others). This didn't solve the problem. I changed configuration to force inital values: "Charge": { "topic": "solpiplog/pip/acoutw", "type": "243", "subtype": "29", "switchtype": "0", "options": {"EnergyMeterMode": 1}, "mapping": {"item": "~*;~0"}, "initial": {"svalue": "0.0;0.0", "nvalue": 0} } Same issue... However everythng is exactly as doc said this should be... I suspected an issue into Domoticz, so I tried the following: 1) deleted the existing device 2) restarted Domoticz, 3) Manually changed type of new device from "Computed" to "From device" 4) Send a change using Mqtt Explorer 5) Manually changed type back to "Comptuted". This started to work... but I don't know why ;-) I'll try to understand going depper in Domoticz code, to see wha't wrong in initial condition. Stay tuned!

FlyingDomotic commented 6 days ago

After more checks, this seems to be a bug in Domoticz. Issue https://github.com/domoticz/domoticz/issues/6194 has been opened to get device properly intialized. Meanwhile, changig twice meter type could help.