ha-smartthinq-sensors
ha-smartthinq-sensors copied to clipboard
[Feature Request] Show energy consumption for my LG Air Conditioner
Hi! I'm using Home Assistant with your excellent module. My mini-split A/C was succesfully recognized as model "RAC_056905_WW-RAC (AC)" and Firmware: 2.5.8_RTOS_3K. It shows 2 entities:
climate.aire sensor.aire_room_temperature
(aire is, of course, the name I gave to my "aire acondicionado" (air conditioning in spanish).
They both work well.
Is there a way I can see the "energy consumption"? In the original LG ThinQ app on Android, I can see an instant measurement of the energy (in Kw) and also an historical energy consumption for day, week, month and year.
Is there a way I can see that consumption (and graph it) on Home Assistant?
You should enable debug and attach here your HA log so that I can check if this information is available in the received data.
Here you are. I started HA, then turned my A/C on, waited some minutes, and then turned it off.
Is this what you want?
Thanks! home-assistant.log
Yes, but unfortunatly I don't find any usefull information in the payload:
{"Operation":"1","OpMode":"0","WindStrength":"8","TempUnit":"NS","TempCur":"30","TempCfg":"25","GroupType":"1","SleepTime":"0","OnTime":"0","OffTime":"0","RacAddFunc":"NS","ExtraOp":"0","DiagCode":"00","TimeBsOn":"0","TimeBsOff":"0","AirClean":"0","AutoDry":"0","PowerSave":"0","WDirVStep":"100","WDirHStep":"100","TempLimitMax":"0","TempLimitMin":"0","DuctZoneType":"0","ZoneControl":"0","DRED":"0","SensorPM1":"0","SensorPM2":"0","SensorPM10":"0","AirPolution":"0","HumidityCfg":"0","WaterTempCoolMin":"NS","WaterTempCoolMax":"NS","WaterTempHeatMin":"NS","WaterTempHeatMax":"NS","HotWaterTempMin":"NS","HotWaterTempMax":"NS","SensorHumidity":"0","TotalAirPolution":"0","SensorMon":"0","CleanDry":"0","ProductStatus":"0","AirMonitoring":"0","Humidification":"0","AirFast":"0","AirRemoval":"0","AirUVDisinfection":"0","WatertankLight":"0","SignalLighting":"0","WDirUpDown":"0","WDirLeftRight":"0","WSwirl":"0","Jet":"0","LowHeating":"0","CirculateStrength":"0","CirculateDir":"0","AntiBugs":"0","IceValley":"0","Humsave":"0","WaterTempCur":"0","HotWaterTempCur":"0","HotWaterTempCfg":"0","HotWaterMode":"0","HotWater":"0","AWHPTempCfgSwitch":"0","AirTempCoolMin":"NS","AirTempCoolMax":"NS","AirTempHeatMin":"NS","AirTempHeatMax":"NS","WaterInTempCur":"0","AWHPWATempControlSta":"0","DisplayControl":"0","SmartCare":"0","TwoSetCoolTemp":"0","TwoSetHeatTemp":"0","TwoSetCoolUSL":"0","TwoSetCoolLSL":"0","TwoSetHeatUSL":"0","TwoSetHeatLSL":"0","TwoSetACOState":"0","TwoSetModeDeadband":"0","TwoSetState":"0"}
Was the application providing information about current consumption? May be you should leave it on sime more time?
Good evening. I am also interested in the issue of instantaneous energy measurement ('airState.energy.onCurrent': 50.0) for thin v. 1 (Detskayanew1). Thank you for this implementation for thinq v. 2 (Spalnyanew) home-assistant.log
oh excellent, you guys beat me to this feature request!
To re-ignite the discussion that was playing over on the megathread :) - i was chatting ages ago with sampsyo (who wrote the original wideq integration) about this but dev never got there. I do still have his working, original version of wideq in my custom_components folder (i.e. custom_components/wideq/ ..... noting this is different code to your fork ollo69 custom_components/smartthinq_sensors/wideq/ as you didjnt seem to port the 'example.py' which you can use to debug the state of the API).
Ive just done some testing with that older wideq ... and confirm i can still get power info dumped to me. i started with just the unit on FAN-ONLY:
i then switched it to heating mode, and watched the watts increase steadily over successive minutes:
next:
then (noting this one has different values... i assume maybe one might be 'last reading' vs 'current reading' or something?):
lastly (and i didnt see it get higher than this - the compressor was running - could hear the outside unit working etc):
then i turned the unit completely off and it dropped back to a baseline (i guess it pulls this in idle mode?):
so it would appear: 1/ the info is there int he wideq API 2/ it seems to be able to query instantaneous Wattage usage (i.e. its not a tally that just keeps getting bigger over the day)
not quite sure how to get the info the others are providing from home-assistant.log Is that just the logging tweak in configuration.yaml?
as usual ollo69 - thanks so much for your time!! we are very appreciative!
Keiran.
Ok, now is clear how to get this additional information for ThinQ1 devices. I will think about this, because it require a different call than the one used for monitoring, I should implement this with a lower rate (e.g. every 5 min.) to not stress the LG cloud. I will think about this...
Yeah 5min sounds sensible to me. We dont want to have our API calls banned! I wonder if they know about our little community of reverse engineers! Haha
not quite sure how to get the info the others are providing from home-assistant.log Is that just the logging tweak in configuration.yaml?
For information (configuration.yaml): logger: default: critical logs: custom_components.smartthinq_sensors: debug
Yeah 5min sounds sensible to me. We dont want to have our API calls banned! I wonder if they know about our little community of reverse engineers! Haha
I tried to implement this feature in last release. Please report results and issues
Oh already?! Wow.
Hmm i just checked the code diff on the last commit - didnt look at all relevant to this? Are you sure you folded this work into your commit?
I still quite sure about what I did.... Why you check last commit, if you want to see diff you have to check all commits from previous release
Ok great! Ill take your word of course. I was just surprised you folded this in so quick. Amazing!
I was just surprised you folded this in so quick. Amazing!
This doesn't means that it will work...😉
So I have a V2 device, and this doesn't appear to be working at all - it is just reporting the baseline consumption regardless of what is happening.
Do we know what the API throttle rate is? - Could we bump the refresh rate up a little? I would have thought that every 30 seconds would be an unreasonable number to be refreshing (surely you could exceed that using an app if you were constantly playing with it).
What did you want for troubleshooting this one?
So I have a V2 device, and this doesn't appear to be working at all - it is just reporting the baseline consumption regardless of what is happening.
And why is not enough? What you was expecting? In HA you have all the tools necessary to calculate specific consumption starting from a baseline.
Do we know what the API throttle rate is? - Could we bump the refresh rate up a little? I would have thought that every 30 seconds would be an unreasonable number to be refreshing (surely you could exceed that using an app if you were constantly playing with it).
Regardless of the refresh rate used by the app, here we are talking about an integration that poll 24h/days the LG cloud, multiplied by all the user that installed it. And we have also to consider that an higher refresh rate for an integration based on cloud polling could break HA state machine. I don't know exactly what you want to do with high refresh rate, generally speaking 30 seconds polling is a good compromise to stay with, also to avoid to be banned by LG.
So I have a V2 device, and this doesn't appear to be working at all - it is just reporting the baseline consumption regardless of what is happening.
And why is not enough? What you was expecting? In HA you have all the tools necessary to calculate specific consumption starting from a baseline.
Basically regardless of how long / hard it is running (i.e. we're seeing sub-zero (celsius) temps, I'm not seeing it exceed 60-70 watts). It once spiked up to 3000 watts in the history, but has not been reliable (it held that for a day before polling again). Not sure how I can calculate the power consumption of an inverter compressor where it is infinitely variable depending on the conditions?
Do we know what the API throttle rate is? - Could we bump the refresh rate up a little? I would have thought that every 30 seconds would be an unreasonable number to be refreshing (surely you could exceed that using an app if you were constantly playing with it).
Regardless of the refresh rate used by the app, here we are talking about an integration that poll 24h/days the LG cloud, multiplied by all the user that installed it. And we have also to consider that an higher refresh rate for an integration based on cloud polling could break HA state machine. I don't know exactly what you want to do with high refresh rate, generally speaking 30 seconds polling is a good compromise to stay with, also to avoid to be banned by LG.
Sorry! - this is my poor typing skills early in the morning. 30 seconds was what I was asking for. I miss typed would for wouldn't. I feel that the data is too variable for 5 minute increments to have much value, whereas 30 seconds allows for enough of an idea as for how it is consuming.
Overall, it basically looks like it's not polling correctly maybe? Just no updates at all (it has run for many hours in the period below, but with no changes to the energy sensor.
Basically regardless of how long / hard it is running (i.e. we're seeing sub-zero (celsius) temps, I'm not seeing it exceed 60-70 watts
I just read information from a variable that seemed to be able to provide that information, but probably it doesn't. I don't have a LG climate device, so someone should try to capture LG app information using an application as mitmiproxy
to identify the right command to be used.
IMO is more simple insert a device like sonoff pow
with tasmota
firmware before the AC power supply, this will provide to HA all the required consumption information in real time.
Sorry! - this is my poor typing skills early in the morning. 30 seconds was what I was asking for
I use 5 minutes rate only to get power consumption for ThinQ1 devices using a dedicate know command. I confirm that all other information are retrieved using 30 seconds polling rate.
I just read information from a variable that seemed to be able to provide that information, but probably it doesn't. I don't have a LG climate device, so someone should try to capture LG app information using an application as
mitmiproxy
to identify the right command to be used. IMO is more simple insert a device likesonoff pow
withtasmota
firmware before the AC power supply, this will provide to HA all the required consumption information in real time.
Completely agree. Unfortunately for a ducted unit, it is hard-wired, and also draws far more than can be run through an in-line power monitor. Best bet is a CT clamp (which I have for other circuits, just not enough inputs to include the AC).
Not to worry though, it was just a 'nice to have', and figured that if it were being implemented that I could try to help get it going.
I am v1. I will test on the weekend (sory work and family hectic during weekdays). Your code may work for me! Ill keep you posted. Is it just an upgrade thru HACS? or a git pull. And how do i know if its working? Will it show up as a new sensor.xxxxxx entity, or perhaps an attribute in the existing climate.xxxxx device? Once i have eyes on that value ill be able to plot it.
And i know mitmproxy well. I can help with reverse engineering the API if need be.
You just have to install the integration via HACS and configure it using workflow, or just upgrade if already installed. Connected to the climate device you should see a new sensor entity, that by default is disabled. Just enable it and check if data match with data in your LG app.
Hi again, so i just upgraded in HACS (now to v0.8.10)... and unless I'm missing something, cant seem to find the new sensor (or at least i don't know how to find it). Heres my state entity for the unit:
and heres my "related entities"
Hi! Congratulations and thank you! It's working!!!
Oh interesting @barajasfernando! Great to see. May i ask what the name of your climate device is? Is it “climate.Aire”. If i search all my states for “Current” i dont see a sensor like yours “….. Energy Current”. Same deal if i search for energy.
I am a ducted AC unit, v1 of the API.
Im going to try uninstall of this thinq component and reinstall again (via HACS). Just In case the workflow only detects the power sensor once when its first installed (and my config is latching onto a version before it existed). Stay tuned.
Fixed and working! Uninstall / reinstall didnt help, but then I remembered about the config -> integrations page for new workflow config options. Went in there and now noticed 3x entities (before it was 2).
FYI @ollo69 it seems i have to manually go in an enable the entity, as its “disabled by the integration” by default (even though “enable new entities” is toggled it didnt seem to work). This may confuse people.
In any case, enabling it and waiting a few mins, i can now see the sensor in my states menu!!
For anyone else hunting for it, it will be called: sensor.xxxxxx_energy_current (where xxxxxx is your LG device name ie climate.xxxxxx)
Oh interesting @barajasfernando! Great to see. May i ask what the name of your climate device is? Is it “climate.Aire”. If i
I can see yours is working now, great!
@ollo69 - thank you so much. I have been wanting this data for years - and after only 1hr, I can see how to drastically cut my energy costs. It was a real surprise for me to see that, when in heating mode (its winter here in Australia), even though ive set the desired temp inside to be lower than the current measured temp (so you would think it would be using not much energy at that point - the noisy outside compressor goes off, so that seemed to confirm theory)..... but apparently not!
this will allow me to tune my automations better - i.e. build my thermostat into HASS rather than let the LG do it. Seems crazy, but, hey, smart home!! thanks again olio. Ill buy you a coffee.
it seems i have to manually go in an enable the entity, as its “disabled by the integration” by default (even though “enable new entities” is toggled it didnt seem to work). This may confuse people.
There are tons of sensors in this integration, and this one do not work for all people. I just enable most important sensors for each devices, other are created in status disabled.
Very good to know that for you is working, but I suspect that this is valid only for ThinQ1 devices. To implement this also on ThinQ2 devices, someone should "sniff" right command from ThinQ app using mitmiproxy
, so that I can implement the right call in integration.
Hi,
My power usage during standby is always 50watts.
When I turn it on, the power difference is visible
Any idea why the unit is using 50watts when turned off? or is this a incorrect reading?
What are the values showed in LG app or directly on the device?
Mine does the same. I can live with it. I saw some chatter about this elsewhere. I think on the ollo69 megathread issue
This is from the LG ThinQ app when off
When on
HA when on
It could be that this value have to be divided by 10?
^ i dont think so. Some quick math: when my unit is really working hard your code is reporting its using 3000W (3kW). When dividing this by Voltage here (240v) - that equals 12.5A of current. It sounds about right to me - given it asks for a 40A circuit breaker on install. So in summary, no i dont believe we need to divide by 10. All this heating / cooling for 1.25A would never be enough…. I think phones pull this when charging haha
Wasn't sure whether to open a new feature request or just add to this one, but I think it's related enough to energy consumption to tack onto this thread.
HA has just updated to include a new Energy tab, which supports adding individual devices to get an overall idea of power consumption. It looks like the requirement for an energy usage sensor to be included in the overview is to add a last_reset property to the sensor https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics
I had a bit of a look at the sensors.py but I'm not... smart enough to propose the exact change. It seems to be as simple as adding last_reset to FEAT_ENERGY_CURRENT
I will take a look to this next w.e.
I will take a look to this next w.e.
Would it be possible to add this consumption into the new Energy feature?
https://www.home-assistant.io/more-info/statistics/
thanks!
This require some review in current code, not so immediate, but I will work on this.
Thanks @ollo69 ! I just watched a vid on this today, apparently the pre-requisites for that new dashboard are pretty simple. The sensor must have these (yellow highlighted) attributes:
heres the vid (a great overview of the new dashboard) https://youtu.be/W7mVagcssZY (see 4m 30s pt for my screenshot above).
Real problem is that I should migrate base class from entity
to sensor
that they introduced some release ago
Ahh i see.
I just released a new version migrating sensors from python class entity
to python class sensor
, but working on this I realize that the sensor that collect the power usage for climate device, cannot have device_class: energy
because it represent current power consumption (W) and not the energy (W/h). Sensor now have the the state_class: measurement
associated but I don't know if this is enough to use it in energy page.
I just released a new version migrating sensors from python class
entity
to python classsensor
, but working on this I realize that the sensor that collect the power usage for climate device, cannot havedevice_class: energy
because it represent current power consumption (W) and not the energy (W/h). Sensor now have the thestate_class: measurement
associated but I don't know if this is enough to use it in energy page.
Thank you for the new version! At least as of now I don´t see the device sensor available within the energy page. Also, it does not seem to be updating it´s values by itself ... but I can tell you that before this update, I had to open the app in my phone so the sensor would pick some value ... thanks for your hard work getting this one fixed! :)
My 1st pic is my refrigerator, it´s picked up just fine in the Energy Page. The 2nd shows your sensor ... I think the differences are the "state_class: total_increasing" Instead of measurement (and the unit of course) and "device_class: energy"
Hey guys. HASS team have provided a way to deal with this problem (power - which is W, vs energy which is kWh - energy dash needs the latter). You define a new sensor like this, and have it linked to your old sensor that only measures W (line 7). Line 8 is the new sensor name that pops up in the energy dash.
Hey guys. HASS team have provided a way to deal with this problem (power - which is W, vs energy which is kWh - energy dash needs the latter). You define a new sensor like this, and have it linked to your old sensor that only measures W (line 7). Line 8 is the new sensor name that pops up in the energy dash.
That´s exactly what I´ve created for mine:
I had the unit_prefix as W so I guess that´s why the Energy page didn´t pick it up ... Thanks!
@ollo69 - do you know what is the refresh interval for the energy meter for your sensor?
thanks guys!
@ollo69 - do you know what is the refresh interval for the energy meter for your sensor?
- For AC device V1 (oldest unit) power data require a specific call that is done every 5 minutes
- For AC device V2 (newest unit) power data is in the payload, so is polled every 30 sec.
Probably data for V1 device is more reliable than data in payload for V2 device, but this is just my supposition (I don't have any LG AC devices)
@ollo69 - do you know what is the refresh interval for the energy meter for your sensor?
- For AC device V1 (oldest unit) power data require a specific call that is done every 5 minutes
- For AC device V2 (newest unit) power data is in the payload, so is polled every 30 sec.
Probably data for V1 device is more reliable than data in payload for V2 device, but this is just my supposition (I don't have any LG AC devices)
Mine is V2, but if you look at the timeframe, it´s not updating as it should.
For me at least, it updates instantly right after I open up the LG app and go to the energy monitor. As soon as I hit that, HA catches and updates. Those intervals were the times that I grabbed my phone and did this thing.
I´ll try to have 100% data collect tomorrow and get back to you on Thursday to see what HA saw vs LG App saw for AC usage.
thanks! :)
I think that update rate depend on device itself. I just can provide polling interval used in integration😉
I think that update rate depend on device itself. I just can provide polling interval used in integration😉
ok cool thanks ... I guess I´ll try another energy monitoring solution, this one unfortunately is not reliable.
Yes i moved to IoTaWatt. Not to undermine at all Ollo’s great work but yeah the API provided power data is not the best. IoTaWatt Is incredible! Im monitor all my mains switchboard circuits now. Its great
Not to undermine at all Ollo’s great work but yeah the API provided power data is not the best
I totally agree with you. I don't think that energy monitor should be based on info provided by AC device. Personally I use Sonoff POW device with Tasmota firmware that provide all required energy data to HA in real time, and are vey cheap. Similar alternative are Shelly devices...
Hey guys. HASS team have provided a way to deal with this problem (power - which is W, vs energy which is kWh - energy dash needs the latter). You define a new sensor like this, and have it linked to your old sensor that only measures W (line 7). Line 8 is the new sensor name that pops up in the energy dash.
That´s exactly what I´ve created for mine:
I had the unit_prefix as W so I guess that´s why the Energy page didn´t pick it up ... Thanks!
@ollo69 - do you know what is the refresh interval for the energy meter for your sensor?
thanks guys!
Can't get this to work for my setup. It won't show in the "Monitor individual devices". Am I missing something?
Hey guys. HASS team have provided a way to deal with this problem (power - which is W, vs energy which is kWh - energy dash needs the latter). You define a new sensor like this, and have it linked to your old sensor that only measures W (line 7). Line 8 is the new sensor name that pops up in the energy dash.
That´s exactly what I´ve created for mine:
I had the unit_prefix as W so I guess that´s why the Energy page didn´t pick it up ... Thanks! @ollo69 - do you know what is the refresh interval for the energy meter for your sensor? thanks guys!
Can't get this to work for my setup. It won't show in the "Monitor individual devices". Am I missing something?
Is the recorder recording it? I had configured my integration sensor without being recorded and then in it doesn't show up. Once I had added it to the recorder, it popped up in the selection list.