Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff POW: tele ENERGY wrong JSON format #1621

Closed
curzon01 opened this issue Jan 17, 2018 · 19 comments
Closed

Sonoff POW: tele ENERGY wrong JSON format #1621

curzon01 opened this issue Jan 17, 2018 · 19 comments
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended

Comments

@curzon01
Copy link
Contributor

curzon01 commented Jan 17, 2018

v5.11.1 MQTT prefix "tele" JSON result for ENERGY is wrong:

Example for v5.11.1 tele ENERGY Json:
{"Time":"2018-01-17T10:49:50","ENERGY":{"Total":1.944,"Yesterday":0.054,"Today":0.037,"Power":10,"Factor":0.43,"Voltage":229,"Current":0.096}

The final close "}" is missing

In v5.10.0 it was correct (due to missing new "ENERGY" object within JSON Object)
{"Time":"2018-01-17T11:27:12","Total":1.945,"Yesterday":0.054,"Today":0.038,"Period":0,"Power":2,"Factor":0.09,"Voltage":231,"Current":0.077}

it might be that the change in 5.11.0
"Change Sonoff Pow Energy MQTT data message and consolidate Status 8 into Status 10"
is incompleted :-)

@arendst
Copy link
Owner

arendst commented Jan 17, 2018

Strange mine look OK:

{"Time":"2018-01-17T11:34:19","ENERGY":{"Total":14.201,"Yesterday":0.064,"Today":0.023,"Period":0.2,"Power":1.9,"Factor":0.16,"Voltage":203.9,"Current":0.059}}
{"StatusSNS":{"Time":"2018-01-17T11:38:28","ENERGY":{"Total":14.201,"Yesterday":0.064,"Today":0.023,"Power":1.9,"Factor":0.18,"Voltage":207.1,"Current":0.052}}}

What's the output of your status 10 message?

@curzon01
Copy link
Contributor Author

Very strange - to write this issue I previously downgraded to v5.10.0 using web interface to my single Sonoff POW.

I now manually upgraded again to v5.11.1 using the webinterface to answer your question - and now, believe it or not, it's solved =:-]

I noticed this issue due to my FHEM expandJSON module, which always complained the MQTT payload:
Bad JSON: SonoffPOW ENERGY: {"Time":"2018-01-17T10:33:06","ENERGY":{"Total":1.942,"Yesterday":0.054,"Today":0.034,"Power":10,"Factor":0.40,"Voltage":230,"Current":0.106}

Before I updated all my Sonoff (>10) with GroupTopic and "upgrade" - so I will close this issue.

I will try to repeat this situation and if it occurs again we can reopen issue.

@curzon01 curzon01 reopened this Jan 17, 2018
@curzon01
Copy link
Contributor Author

curzon01 commented Jan 17, 2018

it happened again - and unfortuanely - it might occuring more or less randomly:

18:59:50 MQT: home/tele/tasmota/SonoffPOW/SENSOR = {"Time":"2018-01-17T18:59:50","ENERGY":{"Total":1.956,"Yesterday":0.054,"Today":0.049,"Period":0,"Power":9,"Factor":0.43,"Voltage":231,"Current":0.089}} (retained)
19:01:56 MQT: home/tele/tasmota/SonoffPOW/SENSOR = {"Time":"2018-01-17T19:01:56","ENERGY":{"Total":1.956,"Yesterday":0.054,"Today":0.049,"Period":0,"Power":9,"Factor":0.43,"Voltage":233,"Current":0.088}} (retained)
19:02:00 MQT: home/tele/tasmota/SonoffPOW/UPTIME = {"Time":"2018-01-17T19:02:00","Uptime":8}
19:03:58 MQT: home/tele/tasmota/SonoffPOW/SENSOR = {"Time":"2018-01-17T19:03:58","ENERGY":{"Total":1.957,"Yesterday":0.054,"Today":0.049,"Period":0,"Power":10,"Factor":0.53,"Voltage":233,"Current":0.077}} (retained)
19:05:00 MQT: home/tele/tasmota/SonoffPOW/MARGINS = {"PowerLow":"OFF"}
19:05:00 MQT: home/tele/tasmota/SonoffPOW/ENERGY = {"Time":"2018-01-17T19:05:00","ENERGY":{"Total":1.957,"Yesterday":0.054,"Today":0.049,"Power":16,"Factor":0.53,"Voltage":233,"Current":0.130} (retained)
19:05:02 MQT: home/tele/tasmota/SonoffPOW/MARGINS = {"PowerLow":"ON"}
19:05:02 MQT: home/tele/tasmota/SonoffPOW/ENERGY = {"Time":"2018-01-17T19:05:02","ENERGY":{"Total":1.957,"Yesterday":0.054,"Today":0.049,"Power":9,"Factor":0.44,"Voltage":233,"Current":0.089} (retained)
19:05:59 MQT: home/tele/tasmota/SonoffPOW/SENSOR = {"Time":"2018-01-17T19:05:59","ENERGY":{"Total":1.957,"Yesterday":0.054,"Today":0.050,"Period":0,"Power":9,"Factor":0.48,"Voltage":233,"Current":0.084}} (retained)
19:08:01 MQT: home/tele/tasmota/SonoffPOW/SENSOR = {"Time":"2018-01-17T19:08:01","ENERGY":{"Total":1.957,"Yesterday":0.054,"Today":0.050,"Period":0,"Power":10,"Factor":0.58,"Voltage":233,"Current":0.070}} (retained)
19:08:13 CMD: status 10
19:10:02 MQT: home/tele/tasmota/SonoffPOW/SENSOR = {"Time":"2018-01-17T19:10:02","ENERGY":{"Total":1.957,"Yesterday":0.054,"Today":0.050,"Period":0,"Power":9,"Factor":0.48,"Voltage":233,"Current":0.081}} (retained)

Have a look at 19:03:58 - it's ok
at 19:05:02 it's wrong and the last char is missing.
The only thing what's happened before the last char was not written is that powelow event occured.

The code above is copied from web interface console but it's the same on MQTT payload and on syslog

@curzon01
Copy link
Contributor Author

I retrieved my logs and it's true: The last char } for SENSOR JSON is missing every time the MARGINS event happened before!

@davidelang
Copy link
Collaborator

davidelang commented Jan 17, 2018 via email

@arendst
Copy link
Owner

arendst commented Jan 17, 2018

It's a reproducable bug! I will investigate.

@arendst arendst added the bug Type - Confirmated Bug label Jan 17, 2018
arendst added a commit that referenced this issue Jan 18, 2018
5.11.1c
 * Make command color parameter input less strict to ease Hass
support
 * Add ColorTemperature to light status message
 * Change
PubSubClient.h define MQTT_MAX_PACKET_SIZE from 512 to 1000 for Hass
support
 * Make define MESSZ dependent on PubSubClient.h define
MQTT_MAX_PACKET_SIZE
 * Fix logging line length around 400 characters
 *
Change module name Wemos D1 mini into Generic (#1220)
 * Revert HTML
change from width=100% to style=width:100% supporting HTML5 (#1358)
 *
Add experimental (still Hass python exceptions) Home Assistant Discovery
for switch and light to be enabled by command SetOption19 1 (#1534)
 *
Updated French Translation (#1561)
 * Fix DS18B20 temperature JSON
decimal dot (#1561)
 * Add Spanish language file (#1589)
 * Update
Italian Language file (#1594)
 * Consolidate WIFI_MANAGER_SEC into
WIFI_CONFIG_SEC (#1616)
 * Fix Energy JSON message (#1621)
@jjlawren
Copy link

I don't see it mentioned in the comments, but the threshold topic is still 'ENERGY'. The POW tele format changed to 'SENSOR' with 'ENERGY' in the payload in 5.11. Shouldn't they be consistent?

@MimbaMonkeyHouse
Copy link

I've got the same issue. Out of 12 flashed POWs, only the three that have not been updated to 5.11.1 are showing energy consumption. I guess they're going back to 5.10 for now...

@arendst arendst added the fixed Result - The work on the issue has ended label Jan 27, 2018
arendst added a commit that referenced this issue Feb 9, 2018
5.12.0 20180209
* Change library PubSubClient.h define MQTT_MAX_PACKET_SIZE from 512 to
1000 for Home Assistant  support
* Change relation of define MESSZ being dependent on PubSubClient.h
define MQTT_MAX_PACKET_SIZE
* Change command color parameter input checks to less strict for Home
Assistant support
* Change command Ina219Mode into command Sensor13
* Change commands HlwPCal, HlwUCal and HlwICal to PowerCal, VoltageCal
and CurrentCal to be used for both Pow and S31 calibration
* Change commands HlwPSet, HlwUSet and HlwISet to PowerSet, VoltageSet
and CurrentSet to be used for both Pow and S31 calibration
* Change uptime from hour to second resulting in a display of
123T13:45:21 where 123 is days
* Change module name Wemos D1 mini into Generic (#1220)
* Change HTML from width=100% to style=width:100% supporting HTML5
(#1358)
* Change OSWATCH_RESET_TIME (Blocked loop) from 30 to 120 seconds to
allow slow networks (#1556)
* Change WIFI_MANAGER_SEC into WIFI_CONFIG_SEC (#1616)
* Change function pointers code to save code space and memory (#1683)
* Change webserver argument processing gaining 5k code space (#1705)
* Change weblog memory usage (#1730, #1793, #1819)
* Update TasmotaSerial library to 1.1.0
* Update language files Italian (#1594), Dutch (#1723) and Spanish
(#1722)
* Fix Non-English JSON temperature unit attachement
* Fix Arilux RF induced exception by moving interrupt handler to iram on
non ESP8266/Arduino lib v2.3.0
* Fix truncated command names and wrong response for DomoticzSwitchIdx
(#1571)
* Fix %-sign issue as printf escape character in Humidity and Sonoff SC
(#1579)
* Fix DS18B20 temperature JSON decimal dot (#1561)
* Fix Energy JSON message (#1621)
* Fix IRSend parameter translation (#1636)
* Fix TSL2561 device detection (#1644, #1825)
* Fix BME680 teleperiod resistance measuring (#1647)
* Fix Energy Monitoring Energy Today and Energy Total reading after
restart (#1648)
* Fix IRReceive Data value (#1663)
* Fix Energy Monitoring Energy Period roll-over (#1688)
* Fix compiler warnings (#1774)
* Fix command PWM response if no PWM channel is configured (#1783)
* Add locale Decimal Separator to Web sensor page
* Add ColorTemperature to light status message
* Add command PowerOnState option 5 which inverts PulseTime and allows
for delayed always on after power on
* Add OtaMagic two step Web server OTA upgrade using filename-minimal
image if OTA free space is too small
* Add support for PMS5003 and PMS7003 particle concentration sensor
* Add command SetOption21 1 to allow Energy Monitoring when power is off
on Sonoff Pow and Sonoff S31 (#1420)
* Add Chinese language file (#1551)
* Add French language file (#1561)
* Add Spanish language file (#1589)
* Add HTTP Allow Cross Origin removed from ESP8266/Arduino lib v2.4.0
(#1572)
* Add Home Assistant MQTT Discovery for switch and light to be enabled
by command SetOption19 1 (#1534) or define
HOME_ASSISTANT_DISCOVERY_ENABLE in user_config.h (#1685)
* Add command State to retrieve device state information (same data as
teleperiod state and status 11 in slightly different JSON format)
* Add optional login to Webserver AP mode (#1587, #1635)
* Add command Sensor15 2 to start MHZ19(B) Zero Point Calibration
(#1643)
* Add support for Sonoff S31 Smart Socket with Power Consumption
Detection (#1626)
* Add command SetOption20 to allow update of Dimmer/Color/Ct without
turning power on (#1719, #1741)
* Add NTP sync time slot based on chip id (#1773)
* Add cursor pointer to web button (#1836)
@chimeranzl
Copy link

5.12.0 appears to shows incorrect ‘current‘ consumption, power (watts) is correct, current too high!

@curzon01
Copy link
Contributor Author

curzon01 commented Mar 3, 2018

@chimeranzl - can not confirmed:

5.10.0

MQT: dev/stat/tasmota/pow/STATUS2 = {"StatusFWR":{"Version":"5.10.0","BuildDateTime":"2017-12-01T13:55:52","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}
MQT: dev/stat/tasmota/pow/STATUS8 = {"StatusPWR":{"Total":5.631,"Yesterday":0.068,"Today":0.011,"Power":9,"Factor":0.51,"Voltage":229,"Current":0.079}}

5.11.1i

MQT: dev/stat/tasmota/pow/STATUS2 = {"StatusFWR":{"Version":"5.11.1i","BuildDateTime":"2018-02-07T07:57:21","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}
MQT: dev/stat/tasmota/pow/STATUS10 = {"StatusSNS":{"Time":"2018-03-03T12:16:33","ENERGY":{"Total":5.631,"Yesterday":0.068,"Today":0.010,"Power":9,"Factor":0.60,"Voltage":229,"Current":0.069}}}

5.12.0

MQT: dev/stat/tasmota/pow/STATUS2 = {"StatusFWR":{"Version":"5.12.0","BuildDateTime":"2018-02-09T14:54:51","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}
MQT: dev/stat/tasmota/pow/STATUS10 = {"StatusSNS":{"Time":"2018-03-03T12:20:24","ENERGY":{"Total":5.631,"Yesterday":0.068,"Today":0.011,"Power":9,"Factor":0.35,"Voltage":228,"Current":0.078}}}

All are the same - try calibrate all three voltage, current and power before measurements

@chimeranzl
Copy link

I get Current reading from the JSON string ENERGY.Current from the topic SENSOR as someone else mentioned above, for me the firmware 5.12.0 does not publish to ENERGY topic anymore unless I manually request it by sending a message to STATUS. See if the current reads correctly from the SENSOR topic for you?

@curzon01
Copy link
Contributor Author

curzon01 commented Mar 4, 2018

Yes, topic SENSOR is the telemetry topic (periodically send by TelePeriod) for Pow and Current value for topic SENSOR is also valid:

Firmware info

CMD: Status 2
MQT: dev/stat/tasmota/pow/STATUS2 = {"StatusFWR":{"Version":"5.12.0","BuildDateTime":"2018-02-09T14:54:51","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}

MQTT SENSOR topic Pow ON

dev/stat/tasmota/pow/SENSOR {"Time":"2018-03-04T14:56:18","ENERGY":{"Total":5.707,"Yesterday":0.077,"Today":0.010,"Period":0,"Power":9,"Factor":0.42,"Voltage":233,"Current":0.077}}

MQTT SENSOR topic Pow OFF

dev/stat/tasmota/pow/SENSOR {"Time":"2018-03-04T15:00:28","ENERGY":{"Total":5.707,"Yesterday":0.077,"Today":0.011,"Period":0,"Power":0,"Factor":0.00,"Voltage":0,"Current":0.000}}

Anyway again and again: Calibrate all three values of Pow before going on...

@chimeranzl
Copy link

chimeranzl commented Mar 4, 2018

openhab/sonoff/poolpump/STATE {"Time":"2018-03-04T23:15:06","Uptime":"2T19:50:17","Vcc":3.476,"POWER":"ON","Wifi":{"AP":1,"SSId":"iotbam","RSSI":52,"APMac":"06:18:D6:C2:05:0B"}}
openhab/sonoff/poolpump/SENSOR {"Time":"2018-03-04T23:15:06","ENERGY":{"Total":27.679,"Yesterday":9.391,"Today":8.577,"Period":5,"Power":851,"Factor":0.42,"Voltage":234,"Current":8.678}}

The above is what Im getting. It is most certainly is NOT consuming 8.6 amps - it is not even rated that high, the device (pool pump) that is plugged into it is on and consuming 851 watts which is correct, at 234 volts and 8.678 amps would imply the pump is drawing 2,030 watts which it is not.

EDIT: as per this #964

it maybe hardware related, i will swap it out for another, test and report back...

@guzzit3
Copy link

guzzit3 commented Mar 4, 2018 via email

@guzzit3
Copy link

guzzit3 commented Mar 4, 2018 via email

@chimeranzl
Copy link

The sonoff powers a controller that has an analog timer on it, and power off to the pool pump. The analog/rotary timer is set to turn on the pump between 8am and 6pm (only use sonoff for power monitoring, not on/off ability) When the timer is off, the pump is obviously off, but the current reading does not change - it stays at 8.6 amps. How can that be?

@guzzit3
Copy link

guzzit3 commented Mar 5, 2018 via email

@guzzit3
Copy link

guzzit3 commented Mar 5, 2018 via email

@curzon01
Copy link
Contributor Author

curzon01 commented Mar 5, 2018

for me I capitulate - nothing about my suggestion to calibrate to rule out e.g. absolutly wrong calculation base...

curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.11.1c
 * Make command color parameter input less strict to ease Hass
support
 * Add ColorTemperature to light status message
 * Change
PubSubClient.h define MQTT_MAX_PACKET_SIZE from 512 to 1000 for Hass
support
 * Make define MESSZ dependent on PubSubClient.h define
MQTT_MAX_PACKET_SIZE
 * Fix logging line length around 400 characters
 *
Change module name Wemos D1 mini into Generic (arendst#1220)
 * Revert HTML
change from width=100% to style=width:100% supporting HTML5 (arendst#1358)
 *
Add experimental (still Hass python exceptions) Home Assistant Discovery
for switch and light to be enabled by command SetOption19 1 (arendst#1534)
 *
Updated French Translation (arendst#1561)
 * Fix DS18B20 temperature JSON
decimal dot (arendst#1561)
 * Add Spanish language file (arendst#1589)
 * Update
Italian Language file (arendst#1594)
 * Consolidate WIFI_MANAGER_SEC into
WIFI_CONFIG_SEC (arendst#1616)
 * Fix Energy JSON message (arendst#1621)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type - Confirmated Bug fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests

7 participants