xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
3k stars 638 forks source link

Sonoff Pow Domoticz #50

Closed xoseperez closed 6 years ago

xoseperez commented 7 years ago

Originally reported by: Zerosub (Bitbucket: Zerosub, GitHub: Zerosub)


The integration in Domoticz works very well. Unfortunately, the sonoff pow is not reporting the power measurements to domoticz. It sends well plaintext info to mqtt, but if i assign an IDX to the Power in the domoticz settings, all that is sent looks like this: { "idx": 7, "nvalue": 2 "svalue": ""}

xoseperez commented 7 years ago

Original comment by Tony in Oz (Bitbucket: oztony, GitHub: oztony):


Great integration with Domoticz.

Using Sonoff POW with firmware 1.9.9 I'm trying to relate & map readings on the Sonoff POW to Domoticz.

Currently I am mapping to Domoticz Voltage, Current, Power & Energy. Energy is always less that 0.005, which would seem to bear no relationship to any value on the Status page.

All work except for Energy. Which Status page value does Energy relate to?

xoseperez commented 7 years ago

Removing milestone: 1.6.0 (automated comment)

xoseperez commented 7 years ago

I'm closing this issue since problems with Domoticz should have been fixed with 1.5.4 and 1.6.0. @Zerosub: I have moved the unstable readings to their own issue (issue #58) since they are not related to Domoticz.

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Perfect thanks ...

1.6.0

Power and energy 2017-02-05 16:43:08.076 MQTT: Topic: domoticz/in, Message: {"idx": 69, "nvalue": 0, "svalue": "24;0.40"}

Voltage 2017-02-05 16:43:08.181 MQTT: Topic: domoticz/in, Message: {"idx": 71, "nvalue": 0, "svalue": "219"}

Will see what this does to my graphs.

Later Ferdie

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


100% fully agree with not spending flash on 2 bytes - these are not remote data loggers. He he - yeah the charts are. I was confused about getting 0Wh values but that must have been domoticz protecting itself in a bad data set.

Recreated the Electricity device, set it to compute receiving date and not saving it to flash 2017-02-05 13:56:04.169 MQTT: Topic: domoticz/in, Message: {"idx": 70, "nvalue": 0, "svalue": "354;0"}

And logging seems to be working perfect on graphs and the summary tile.

happyfish.JPG

happyfish1.JPG

Later Ferdie

xoseperez commented 7 years ago

I'm not sure about aggregating energy. I don't like the idea of writing a whole page to flash every minute just for 2 bytes. Setting the energy read to "computed" in Domoticz works fine with incrementals. I will be reporting values with 2 decimal positions too to improve precision. The only drawback is that if you lose messages you don't know what happened. These changes will go live in 1.6.0.

BTW, @FFish, Domoticz charts are really confussing. The energy histogram is centered in the hour while dots in the power line are drawn in the vertical of the timestamp (with a 5 minutes interval, not when it receives the data). That means the energy has a half an hour shift.

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


See you are already committing explicit rom commit changes ..

For now on 1.5.4 I have just done a quick hack.

Before 2017-02-05 03:06:25.221 MQTT: Topic: domoticz/in, Message: {"idx": 68, "nvalue": 0, "svalue": "137;1211"}

After 2017-02-05 03:10:51.475 MQTT: Topic: domoticz/in, Message: {"idx": 68, "nvalue": 0, "svalue": "146;0"}

#!arduino

emon.ino
137            _energy = 0;
138            //saveEnergy();

pow.ino
246            _energy = 0;
247            //saveEnergy();

In theory I should be back to the same MQTT message you had in 1.5.3 that was working on the device. I suspect - busy testing that for the Electricity device on domoticz if the counter is not zero and you have it set to compute, the summary calculations are correct but the graphs do not show the correct value ?? Bit confused here so busy testing, could just be a corrupt data set.

Later Ferdie

xoseperez commented 7 years ago

Sending Current and Volatge to Domoticz is a good idea. I'm creating an enhancement issue to do it. @ToniAr I like the idea of sending incrementals too, writing to EEPROM every minute might not be a good idea. It's emulated in FLASH.

xoseperez commented 7 years ago

@etatto Wow, it looks great!

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


That did not work as expected on domoticz.

MQTT: Topic: domoticz/in, Message: {"idx": 68, "nvalue": 0, "svalue": "358;395"}

but the graph is not showing the correct energy usage.

300wha.JPG

Set it back to compute .. will pay a bit more tomorrow, need to get some lights out on the tanks.

Later Ferdie

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Did the OTA to 1.5.4, very easy must say.

Getting the correct MQTT string MQTT: Topic: domoticz/in, Message: {"idx": 68, "nvalue": 0, "svalue": "360;39"}

Using the same device on domoticz, but changed it to energy from device. Switched of the light on at 20:00 so lets see how things go.

Later Ferdie

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Indeed - I have come to realise one issue with relying on domoticz, accuracy. It could well be that the on device incremental is more accurate than allowing domoticz to do the math - at minimum it could be a resolution thing.

I will flash to 1.5.4 tonight and should be able to see the difference in reporting between the two compute vs from device - since domticz has been doing the math today. 300wh.JPG My load is a consistent 330Wh when the lights are on.

Later Ferdie

xoseperez commented 7 years ago

Original comment by ToniA (Bitbucket: ToniAr, GitHub: ToniAr):


I would want to see a separate incremental feed to Domoticz, i.e. the difference in Watt-hours since the last MQTT message. This way the firmware would not need to write into the EEPROM (are there any obvious ROM wear issues with the way the state is preserved at the moment? is it really EEPROM, or EEPROM emulation in FLASH?)

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Looking at my efergy monitoring - via SDR. Domoticz02.JPG

I am going to switch the fishroom sensor to the same dummy sensor as that of the efergy but use compute instead of the device providing the value. For Domoticz use it would then mean that adding any extra advanced power publishing would be irrelevant. Getting Current and Voltage via MQTT (separate feeds) would be nice.

Domoticz03.JPG

Later Ferdie

xoseperez commented 7 years ago

Original comment by f-fish (Bitbucket: f-fish, GitHub: Unknown):


Hi all, been using espurna now for 14 hours - perfect for the POW. 1.5.3 with domoticz 3.6588

2017-02-03 19:32:23.536 MQTT: Topic: domoticz/in, Message: {"idx": 64, "nvalue": 0, "svalue": "132;0"}

gives me a perfectly usable graph power04.JPG

Not sure writing stuff to EEPROM is really needed and if it is something that is being planned maybe it can be optional and not forced by default.

"Do you think it makes sense to publish day/week/month average/max values too?" for me no not really, but making it a tick to enable advanced power publishing - sure. I would rather want to see published the devices uptime on MQTT. (I am still reading wiki and posts so this might already be a feature)

Later Ferdie

PS - thanks for the effort that has gone into espurna ... very clean.

xoseperez commented 7 years ago

Original comment by Emmanuel Tatto (Bitbucket: etatto, GitHub: etatto):


My dashboard for one Pow: PowNRDahboard.PNG

xoseperez commented 7 years ago

Original comment by Emmanuel Tatto (Bitbucket: etatto, GitHub: etatto):


My 2-cents : I currently store the Power from the MQTT message with a timestamp in a mongodb collection so I can aggregate as I wish : last 24h, last week, etc... All can be done easily with Node-Red ;-) Perhaps it make more sense to send a JSON via MQTT with all the readings (powers, current, voltage) and a timestamp.

xoseperez commented 7 years ago

@Zerosub I have also noticed those spurious values but not as frequently. But since it's not related to the integration to Domoticz I think we should open a different issue for those.

xoseperez commented 7 years ago

Pushed that change to master branch as 1.5.4. I have also an open question about energy measurement: I think it makes sense for the device to do the calculation, but right now I'm just aggregating the value (power * time) and storing it in EEPROM to be able to resume after a reboot (I don't really like it). Do you think it makes sense to publish day/week/month average/max values too? How (API, MQTT,...)?

xoseperez commented 7 years ago

Original comment by ToniA (Bitbucket: ToniAr, GitHub: ToniAr):


Now, after a few hours of reporting to Domoticz, it seems that I get the right energy consumption results if I just change the data type of 'window' from 'unsigned long' to 'double'.

xoseperez commented 7 years ago

Original comment by ToniA (Bitbucket: ToniAr, GitHub: ToniAr):


The energy measurement does not work, it always gives 0. The problem seems to be on this row:

#!arduino

unsigned long window = (double) POW_REPORT_EVERY * POW_UPDATE_INTERVAL / 1000.0 / 3600.0;

The result of the calculation is 0,0166666666666667, which is 0 when assigned into an integer type (long).

xoseperez commented 7 years ago

Fix released with version 1.5.3

ahmeaqas commented 5 years ago

how can we log energy data in domoticz? so that we can have a look on to how much kwh energy consumed by an appliance in a month. should i link espurna domoticz energy idx to electric (instant + counter)? I m using sonoff pow r2.