revk / ESP32-Faikin

ESP32 based module to control Daikin aircon units
GNU General Public License v3.0
354 stars 52 forks source link

the S21 Protocol has Power Meter ? #101

Closed metarutaiga closed 3 months ago

metarutaiga commented 10 months ago

Is the FM Meter? Is the FP Pulse? The values are Hex values.

I checked it on my FTXM-V. The value is likely my Power Meter closely.

kWh = FM * FP / 1000.

revk commented 10 months ago

Do you have examples of the exact messages. If we can work out what they are, I am happy to add that.

metarutaiga commented 10 months ago

FM : 02.47.4D.37.33.31.32.61.03 FP : 02.47.50.45.32.30.30.6E.03

FM : hex(2137) = 8503 FP : hex(2E) = 46 391 kWh = 8503(Meter) * 46(Pulse) / 1000(kilo)

revk commented 10 months ago

I am not sure what you mean by "meter" and "pulse" to be honest - what are their units? Also seems very inconsistent to be using ASCII HEX, but possible.

MassiPi commented 10 months ago

what request are you using to get these values? and what is this measuring? seems total energy used, since when?

metarutaiga commented 10 months ago

image This is my Daikin of Home Assistant. I don't know what is FP / FM, I just guess what it means. I compared it with my power wires Amp. So I guess kWh = FP * FM / 1000.

revk commented 10 months ago

I am not sure how useful a cumulative kWh is? It would help to know what FP and FM are. How/when are they ever reset I wonder.

metarutaiga commented 10 months ago

https://github.com/home-assistant/core/blob/57337b5cee5a5ab076ab89ded23219b40497e6b8/homeassistant/components/daikin/sensor.py#L132

I know it in the Home Assistant first time. But now the WiFi module was updated by MobileApp and disabled local HTTP API, So the Home Assistant can't read it anymore. So I check what the meter command is.

JeanOlivier commented 8 months ago

But now the WiFi module was updated by MobileApp and disabled local HTTP API

This is why we need a project like ES3P32-Faikin, oh my.

44616E commented 5 months ago

This would be very useful for my use case, I was thinking of adding Current transformers on the AC feed, but if the air con can tell me that would be very useful. I'm trying to prioritize solar consumption

revk commented 5 months ago

OK do we know the units of the component parts yet?

sjaakie09 commented 4 months ago

hello revk i mad some nice images you can also use for others faikin_layout and I like the tool a question did you also did things on using esp32 for metering like connecting it to puls gas or modbus rs485 kwh meters?

revk commented 4 months ago

That pin numbering is backwards, but nice pictures.

sjaakie09 commented 4 months ago

Beste, Dear, is it wrong?

Met vriendelijke groet / With kind regards, @.https://comm-co.com/jm2/ Jacques Duerinck CEO @*.**@*.***>

Comm-Co B.V. Kreekzoom 9 4561 GX Hulst The Netherlands Tel: +31 114 370030 GSM: +31 653 120 225 @.**@.https://ewheelz.nl/[created with MySignature.io]https://twitter.com/atexshop[created with @.***https://nl.linkedin.com/in/jacques-duerinck?challengeId=AQHAi-Fs0-Lh1wAAAYvdylK2ok7NzA6irP0R6i52tF08AkW-uyQBCxRVPtwfspwwReWjC6m5WFdCVpc4-Tuff_-GepJXMa6EQQ&submissionId=abb2045a-0071-9817-4aea-279bfae4233d&challengeSource=AgHJcnaeiOppRQAAAYvdyuWbNO7oSDhbmuPQZCGvfX6Uxe5Sc8Mdb7a4KhBRlzM&challegeType=AgH7_Hj09W8F_QAAAYvdyuWers9w2E30FsryCkBCK1SatbG_yKhyvXU&memberId=AgECOEUb0_Rl1AAAAYvdyuWgmmRlgfXI-eqOta-QLfeZUw0&recognizeDevice=AgEl9duzUhSpagAAAYvdyuWjz6GgpYneL-OCQDE_uC4-rxQ0V2WB

Van: RevK @.> Verzonden: dinsdag 12 maart 2024 20:26 Aan: revk/ESP32-Faikin @.> CC: Jacques Duerinck @.>; Comment @.> Onderwerp: Re: [revk/ESP32-Faikin] the S21 Protocol has Power Meter ? (Issue #101)

That pin numbering is backwards, but nice pictures.

— Reply to this email directly, view it on GitHubhttps://github.com/revk/ESP32-Faikin/issues/101#issuecomment-1992382211, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BF7WC5YJNJ2ZB5HZGRSZL3LYX5JEXAVCNFSM6AAAAAA4J5XPIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJSGM4DEMRRGE. You are receiving this because you commented.Message ID: @.**@.>>

revk commented 4 months ago

Just the numbering, pin 1 is the 5V.

I am also not sure how this image relates to the topic of this issue.

sm-Fifteen commented 4 months ago

I am not sure how useful a cumulative kWh is? It would help to know what FP and FM are. How/when are they ever reset I wonder.

It's pretty standard actually to have some kind of lifetime summation as the metric for energy usage, instead of having the accuracy of that metric depend on how often the server polls the device. Most ZigBee devices that measure electricity will report lifetime energy use over the smart power metering cluster as CurrentSummationDelivered, sent as a uint48 with a device-supplied multiplier, divider and unit of measure. 48 bits unsigned is big enough that (even in Wh) it wouldn't wrap around before 248 billion kWh, which seems to be roughly the amount of electricity that a country like Norway consumes over a year.

Likewise, Home Assistant doesn't use power sensors directly for its energy monitoring feature, and you need a virtual sensor that calculates the integration of that power reading if cumulative energy isn't reported.

revk commented 4 months ago

OK so are they cumulative somehow, what are they and what units?

sm-Fifteen commented 4 months ago

OK so are they cumulative somehow, what are they and what units?

OP said they matched the readings on their power meter (in watt-hours) pretty closely when multiplied together, though I guess further testing would be needed to know what either factor represents and what that power consumption covers and excludes (like whether the values always match on multi-zone systems).

I have yet to recieve and install my own Faikin dongles, though, so I can't help with that right now.

revk commented 4 months ago

Ok "when multiplied together". So what are the two values exactly?

44616E commented 4 months ago

Can I query these values through MQTT as a custom command? I should be able to compare the values to a smart meter in the board to confirm if it

revk commented 4 months ago

There are debug messages to allow you to send any S21 command and see replies. The manual should cover it all.

sm-Fifteen commented 3 months ago

FM : 02.47.4D.37.33.31.32.61.03 FP : 02.47.50.45.32.30.30.6E.03

FM : hex(2137) = 8503 FP : hex(2E) = 46 391 kWh = 8503(Meter) * 46(Pulse) / 1000(kilo)

Do these look like valid custom commands/payloads? GM7312a and GPE200n? OP called them FM amd FP, but they seem to be GM and GP from the hex codes, which would correspond with most other polling messages being G.

revk commented 3 months ago

Ok back to what is asked before.

What are "meter" and "pulse" and what units are they?

sm-Fifteen commented 3 months ago

Ok back to what is asked before.

What are "meter" and "pulse" and what units are they?

@revk : I believe that was OP trying to figure out what the values mean based on the ASCII letters, but I don't think they mean anything.

EDIT: As for the units, that's not going to be easy to describe without some additionnal datapoints, which I'm not able to collect yet. I was hoping someone, maybe 44616E, would capture some of those so that we have more data to work with and figure out what they both mean.

sm-Fifteen commented 3 months ago

FM : 02.47.4D.37.33.31.32.61.03 FP : 02.47.50.45.32.30.30.6E.03 FM : hex(2137) = 8503 FP : hex(2E) = 46 391 kWh = 8503(Meter) * 46(Pulse) / 1000(kilo)

Do these look like valid custom commands/payloads? GM7312a and GPE200n? OP called them FM amd FP, but they seem to be GM and GP from the hex codes, which would correspond with most other polling messages being G.

Oh, I only just found this page, I now understand that G is for reply payloads and that the ASCII transcriptions I wrote down are not valid requests, but actually responses. Assuming OP is right (would need more testing to find out whether or not he is) and these are integer values transmitted as hexadecimal ASCII strings (which I guess could make sense for unbounded multi-byte values?), the return value GPE200n is to be interpreted as F/G field "P": 0 0 2 E and decoded ax 0x002E = 46.

Should I understand that all one needs to run to get these values is mosquitto_pub -h 'my.mqtt.server.local' -t 'command/MyDaikinHostname/send' -m 'FM'?

revk commented 3 months ago

Maybe, maybe FP too.

sm-Fifteen commented 3 months ago

Can I query these values through MQTT as a custom command? I should be able to compare the values to a smart meter in the board to confirm if it holds true for my units as well.

@44616E: If you have a chance to test this on your end, you can use these commands and see if the readings match with your own measurements.

mosquitto_pub -h 'my.mqtt.server.local' -t 'command/MyDaikinHostname/send' -m 'FM'
mosquitto_pub -h 'my.mqtt.server.local' -t 'command/MyDaikinHostname/send' -m 'FP'
serimi89 commented 3 months ago

Played around with this today, the FP message (GP result) did not change. It was: {"protocol":"S21","dump":"024750443730307203","GP":"D700"}

Regarding the FM (GM result) messages I could see the below values: 14:18 / AC OFF {"protocol":"S21","dump":"02474D323233335E03","GM":"2233"} 14:50 / AC OFF {"protocol":"S21","dump":"02474D323233335E03","GM":"2233"} 14:51 / AC TURNED ON 14:54 / AC ON {"protocol":"S21","dump":"02474D333233335F03","GM":"3233"} 14:57 / AC ON {"protocol":"S21","dump":"02474D343233336003","GM":"4233"} 15:05 / AC ON {"protocol":"S21","dump":"02474D353233336103","GM":"5233"} 15:11 / AC ON {"protocol":"S21","dump":"02474D363233336203","GM":"6233"} 15:18 / AC ON {"protocol":"S21","dump":"02474D373233336303","GM":"7233"}

So obviously, something is counting. If we compare this to the the kWh on my power meter, it seems like it is incrementing by 0.1kwh every time the GM value increases.

Screenshot 2024-03-21 at 15 22

Ok just like me you were wondering what comes after 9233, so here we go: {"protocol":"S21","dump":"02474D413233336D03","GM":"A233"} {"protocol":"S21","dump":"02474D423233336E03","GM":"B233"}

Hope this helps, If you need anything else, please let me know!

Seb

revk commented 3 months ago

OK, now makes more sense.

I suspect GP is telling you that it meters pulses every 125Wh and is a fixed value.

I suspect GM is a meter telling you how many GP sized pulses.

OK, now to work out how best to report it, and handle meter wrap around.

Anyone know the HA config that would make sense for a "meter" like this?

revk commented 3 months ago

I have made a beta with a Wh report, see if that makes sense.

No HA config yet, let me know what HA config it would need?

serimi89 commented 3 months ago

Great - just installed it and getting values. How do you know its 125Wh per pulse?

I have had some sensors that report Wh and imported it through the Utility Meter integration: https://www.home-assistant.io/integrations/utility_meter/ This can then be added to the energy dashboard to see time based stats.

revk commented 3 months ago

That is what you said in the GP response. It uses whatever comes in on the GP from your unit.

serimi89 commented 3 months ago

well, I cant see the exact number since the internal meter of the AC and my energy meter are not in sync, both having different starting points, so I assumed it was 100Wh since that ballparks the increase of the energy meter (also its the smallest unit of the ONECTA App).

The values that are reported on the Wh value in the latest beta however are counting down: 159939 159861

revk commented 3 months ago

LOL, I'll investigate. It was just the first attempt.

revk commented 3 months ago

Your quoted D700 with is 125

serimi89 commented 3 months ago

Your quoted D700 with is 125

Ah! :)

LOL, I'll investigate. It was just the first attempt.

Haha.. well now I am at 2333, earlier it was 2233 - so obviously it increments the second digit, then the third, etc.

I dont know though if it counts until 1-Z or 1-C or whatever.. 🤣

revk commented 3 months ago

It's hex, and looks like I had an error, new beta in a moment.

revk commented 3 months ago

I think this looks better now, try that.

(BTW it seems my unit uses 165Wh pulses).

serimi89 commented 3 months ago

works! got a 125Wh increase :)

That total number that I am getting must be the total lifetime Wh then?

revk commented 3 months ago

I expect so, and will wrap around at some point I guess.

I'll have to look in to HA, but glad we got to the bottom of what the fields mean.

serimi89 commented 3 months ago

in order to get a daily consumption value in HA from any sensor value, I used the below code. This will reset itself to 0 every day at midnight and can be added to the energy dashboard as a device, monitoring its power consumption over time

utility_meter:
  energy:
    source: sensor.energy_in_kwh
    cycle: daily
sm-Fifteen commented 3 months ago

I have made a beta with a Wh report, see if that makes sense.

No HA config yet, let me know what HA config it would need?

Not sure how it works with MQTT-based devices, but the built-in Daikin integration just registers a few sensors so Home Assistant creates entities for them, and these entities (only the energy ones, in kWh) can then be added to the energy dashboard.

sm-Fifteen commented 3 months ago

in order to get a daily consumption value in HA from any sensor value, I used the below code. This will reset itself to 0 every day at midnight and can be added to the energy dashboard as a device, monitoring its power consumption over time

utility_meter:
  energy:
    source: sensor.energy_in_kwh
    cycle: daily

You don't need to make them cycle for them to work in the energy dashboard. My Zigbee devices just keep going up forever, and the dashboard just considers the difference between the value at the start of a time period compared to the end.

44616E commented 3 months ago

Just tried the beta firmware and the Wh is about 2.8 times higher than it should be. Which seems to correlate with my GP value of 280 (at least that the increment in Wh). Perhaps GM is actually at a fixed multiplier and doesn't need to be multiplied by GP.Will collect some more data over the weekend.I'm also interested if we can get the realtime power value in Watts it exists in that home automation configuration linked to earlier. Not sure how you go from there to the commands.

MassiPi commented 3 months ago

how is this working in a multi-split solution? i assume all splits are reporting the same value, that is the "system" consumption, right? my splits are still in winter mode so i can't test anything atm :)

revk commented 3 months ago

No clue, sorry.

MassiPi commented 3 months ago

thanks anyway :) quite curious to know if these FP and FM are working also on old units (my FTXSxxG splits aren't even officially supported by daikin wifi cards..)

44616E commented 3 months ago

I don't think these power measurements have anything to do with wifi adapters. I suspect its for building management systems like used in Hotels and offices etc. The daikin app doesn't show power usage.

sm-Fifteen commented 3 months ago

Just tried the beta firmware and the Wh is about 2.8 times higher than it should be. Which seems to correlate with my GP value of 280 (at least that the increment in Wh). Perhaps GM is actually at a fixed multiplier and doesn't need to be multiplied by GP.Will collect some more data over the weekend.I'm also interested if we can get the realtime power value in Watts it exists in that home automation configuration linked to earlier. Not sure how you go from there to the commands.

@44616E: There are also other unknown fields under the F command that could be involved in power readings:

The basic polling loop seems to consist of F/G commands: 2, 1, 3, 4, 5, 8, 9, 6, 7, B, G, K, M, N, P, Q, S, T, U, U (again), X, and less frequently R/S commands: H, N, I, a, X, d, L

There might be other values involved in the energy calculations among these, and possibly a real time estimation of power consumption. I'm also guessing state indicators like "Stand by for defrost/hot start" and "Changeover controlled by the master indoor unit" like we see on the more advanced wired thermostats might show up.

serimi89 commented 3 months ago

I am happy to help testing various commands, can someone explain to me how to read / convert the results? as far as I understood they are hex, but also reversed?

serimi89 commented 3 months ago

I am happy to help testing various commands, can someone explain to me how to read / convert the results? as far as I understood they are hex, but also reversed?

Well, correct me if I am wrong, but some values need to be converted to decimal, others are fine as hex, but its always inverted.

I wonder if FM / GM is not simply counting up the kWh, in my case the value is 13123 (hex: 3343), which could be 1312,3 kWh and which is incrementing by 0.1 kWh as seen here. This would match the ONECTA App, where 0.1 kWh is the smallest unit. I dont have consumption data before last year (2023: ~500kWh), but if its a lifetime value, It could make sense since I have my AC almost 3 years.