arendst / Sonoff-MQTT-OTA-Arduino

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE - Now EOL
618 stars 197 forks source link

POW triggered telemetry data? #236

Open Reinhartd opened 7 years ago

Reinhartd commented 7 years ago

Hello, when i switch the POW ON or OFF, then i must wait the telemetric period before i see power data. Can you trigger to send telemetric data when the powerstaus is changed, then we get immediate feedback.

LG Reinhart

patbeirne commented 7 years ago

Reinhard,

The immediate feedback come in a "stat" message.

For example, if you send the command: cmnd/mylight/power1 on the Sonoff will reply immediately with stat/mylight/POWER1 ON

The "tele" message are sent periodically by the Sonoff to inform you of slow-changing or long-term states.

Hogesyx commented 7 years ago

Reinhartd,

I understand your use case, this is that I do.

Your automation bus or the receiving unit should be the one that determine when they need the data. So for example your usual teleperiod might be 300 seconds, but it is possible to code the automation bus to send out a MQTT message to inform the sonoff to change to whatever interval(for example i use 5s) upon a POWER ON, then upon receiving a POWER OFF, it set back to 300 seconds.

Maybe we could split the TelePeriod to PowerOffTelePeriod PowerOnTelePeriod, but I still think that behavior such as this should be manage by the automation bus rather than end point.

littlebilly commented 7 years ago

@Hogesyx I think this is the right intention of Reinhartds suggestion. Nevertheless it would be nice if Theo could implemet this into the code. Just trigger the "tele/pow1/.." regarding Power ON / OFF. An other open point which in my opinion only could be solved by Theo is the the following: If for example the VOLTAGE would fall suddenly from 220 to 110 you never will get an alarm via MQTT in the teleperiod slot. I might be wrong? Hope this helps to get th idea behind and may be a solution by Theo.

Reinhartd commented 7 years ago

@patbeirne

it is right, when i send the command "cmnd/pow1/power1 on"
then Sonoff will reply immediately with stat/pow1/POWER1 ON, but i get no information of current, voltage or power. This information i get only in the next teleperiod!

I would like to see these data immediately: tele/pow1/CURRENT_POWER 53 tele/pow1/VOLTAGE 214 tele/pow1/CURRENT 0.247

LG

Hogesyx commented 7 years ago

@littlebilly I know what he needs, but messing with random telemetry call kind of defeat the purpose of telemetry period, which provides a more or less accurate data point interval. Maybe instead of pumping out as telemetry, the initial power data can be pushed out as STATE instead.