Closed miit86 closed 2 years ago
By the way can you posing the quirk that is working so other user can testing it and getting there devices getting little taste of the power Metering (little high but still working ;-)) ).
Adminiuga have doing it for tuya AIR but is using tuya PD and not normal Zigbee clusters like your device but perhaps its one clue how to do it. https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/air/__init__.py I looking little more around for hacks.
Bitron/SMaBiT thermostats is "patching" the battery and adding it in one new cluster so i thing its one good example how to do the "new" patched cluster. https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/bitron/thermostat.py.
Then its "only" putting in the multiplexer with "normal" way like "new" attribute = old * 100
i think (= not knowing)
One more IKEA thing !!
IKEA controllers is reporting battery then full as 100% and Zigbe shall doing it as 200% (very old Zigbee device was having 2 barristers more modern is only using 1) . In this is the 2* being done and also the cluster https://github.com/zigpy/zha-device-handlers/blob/83624ba2dea5bfb8af2c489211e26c877ca01c35/zhaquirks/__init__.py#L172 .
I think its easiest making the same and using the "new" cluster in the replacement but implanting it in tuya __init__.py
or in your quirk if no more devices is needing it.
Its looks very easy and short implanting only changing the name of the cluster and attribute and the multiplier :-)))
I have making one PR #1056 that is implanting the power on state in the tuya INIT and also removing it in the plug.py and adding the new on/off cluster in it and renaming plug.py to ts0121_plug.py. #1055 So your quirk can being named ts011f_plug.py and also using the power on state from the INIT.
I think i shall doing the same for TS0101 then i have getting 2 LIDL outdoor plugs but need writing one quirk for it :-(((
Hi Matt,
Using the power on state from the INIT is cool. But plug.py only has lines for power on state. is it absolute then? I will name my quirk ts011f_plug.py
I'm not used to code, so it's difficult to understand how to build it.
If I add this below I will get a new output. also see replacements But I have no clue on how to change the numbers from metering and change it before HA gets the numbers.
class TS011FMetering(Metering):
"""Reported Value from current_summ_delivered dived by 100. """
current_summ_delivered = 0x00
current_summ_delivered = current_summ_delivered / 100
Replacements:
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOffRestorePowerCluster,
TS011FMetering,
ElectricalMeasurement.cluster_id,
0xE000, # Unknown
0xE001, # Unknown
I think using this from the quirk root INIT:
class DoublingPowerConfigurationCluster(CustomCluster, PowerConfiguration):
"""PowerConfiguration cluster implementation.
This implementation doubles battery pct remaining for non standard devices
that don't follow the reporting spec.
"""
cluster_id = PowerConfiguration.cluster_id
BATTERY_PERCENTAGE_REMAINING = 0x0021
def _update_attribute(self, attrid, value):
if attrid == self.BATTERY_PERCENTAGE_REMAINING:
value = value * 2
super()._update_attribute(attrid, value)
and changing the cluster name PowerConfiguration
to wot you will changing.
Then is the attribute you like changing BATTERY_PERCENTAGE_REMAINING = 0x0021
to your attibute.
And the recalculating is made with value = value * 2
so making your / 100 instead.
Edit: the class name need being changed 2.
Edit 2: updating the attribute name in if attrid == self.BATTERY_PERCENTAGE_REMAINING:
.
Something like this:
class DividingMeteringCluster(CustomCluster, Metering):
"""Metering cluster implementation.
This implementation divides the KwH for tuya devices
that don't follow the reporting spec.
"""
cluster_id = Metering.cluster_id
current_summ_delivered = 0x0000
def _update_attribute(self, attrid, value):
if attrid == self.current_summ_delivered:
value = value / 100
super()._update_attribute(attrid, value)
how to implement this in my quirk?
I think its looks OK but im no code worrier :-((
If its only used for your device in then in your quirk and if its being used for more devices in the tuya INIT or if global in the quirk root INIT = in your device quirk.
I dont knowing if its need more imports but try putting it in.
Do it like the power on state state class is made (same line spaces before and after). And run black after before you is putting in your system then if its bad formatted it can being that HA is not starting
Hi,
WauW, That worked :P ..! Very Nice :)
So you is having your server only using 0.19 kWh now ?
And the plug have power state off after power loss ;-))))
Still have to test a hour. but the Graph went from 1080 to 10.80. All the graphs of my plugs. Yes: Power State is working.
Just one more 2 go: :)
I also have readings for: rms_current (id: 0x0508) 1195 should be 1.195 see below rms_voltage (id: 0x0505) 224 Correct active_power (id: 0x050b) 194 Correct
Z2M
endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {acCurrentDivisor: 1000, acCurrentMultiplier: 1});
But only the sensor for Active Power is Created in HA. Is this a problem in HA or ZHA or the quirk?
If you can do reading from cluster commands / reading attribute, then the Zigbee part is OK. It can that (Z)HA is not making sensor for all cluster you is having (like the old problem that is fixes in the beta now).
For the wrong current do one more attribute patching class and fixing it like you was doing with the / 100 and it shall working.
Also look in the HA log with debug enabled and you can see then the device is reporting and how its doing it.
Yes,
It's Oke now. from 10.8 KwH to 11.0 KwH in an hour.
How can is share this quirk?
The radio is only sending receiving wot devices is sending and the radio lib plus Zigpy is only piping it to ZHA that only understanding "pure Zigbee" so its work OK with devices that is making all OK. If the device is doing somthing bad then the quirk can correcting it and ZHA is getting "pure Zigbee" and all is working OK.
HA is only getting the last summered consumption and is adding it to the graph with little logic for if have missing some reports and if the device have resettled the counters so it shall starting from zero.
You can doing one PR for adding the code and if you is getting problem i can trying helping you with fixing the tests that normally making one PITA. If you is having the quirk file made you can starting with "adding file" in the tuya folder and making one new file (with the name of your quirk file) and adding the code in it and then making one pull request after saving it to the dev branch.
Or I can do it but if i do changes i need help from you for testing that all changes is working OK or the devs is not accepting the PR if its not tested in real.
The PR looks good but the devs must approving the tests and hope its working OK. Your quirk is using only the TS011F so its no need writing all devices that shall working but its OK. Its good putting one link to the devise request issue and is doing it with "fixing" before its automatic closing the request.
Yes but in the PR so the devs can see wot is made and how its working :-))
The checks was all OK only that David need approving one more time for rerunning it after the last extra "Zero" that was added ;-)
If you have getting one PR merged the system is making the checks without the devs need making anything and its easier.
Hi, I saw the Mistake, corrected it. I learned a lot these past days. Thanks for you Help. :)
When will it be available for everyone.?
If David is approving it and making one new ZHS_quirk for the HA beta it can going in HA 2021.10 but i think its too late for that.
Hi have proving the TS0121 name changes and using MODEL so that is in the dev branch now.
@Hedda
https://github.com/home-assistant/core/pull/56909 It's a merge for Current en Voltage from Zigbee devices.
I use HA Beta. And HA doesn't make sensors for Current en Voltage from my tuya device I can see the values in Clusters.
I don't see anything for Tuya devices. but maybe their created from general code. I try to understand the process and code. maybe something with discovery.
@Hedda
home-assistant/core#56909 It's a merge for Current en Voltage from Zigbee devices.
I use HA Beta. And HA doesn't make sensors for Current en Voltage from my tuya device I can see the values in Clusters.
As wrote in https://github.com/zigpy/zha-device-handlers/issues/910
If I understand the last comment from Adminiuga in PR for ZHA in Home Assistant core home-assistant/core#56909 the ZHA integration component in Home Assistant could now be extended with other attributes on the electrical measurement cluster but have not yet so those you either have to code and submit that as a PR to Home Assistant core yourself or post a feature request on the Home Assistant community forum. Only once those are attributes are support by the ZHA component in Home Assistant core can you make quirks for them if available from the device and needed.
"Support for other attributes could be extended later, as I couldn't find too many devices other than Sinopé RM3250ZB Electrical Load Controller – 50A – Zigbee https://www.amazon.com/dp/B07CGJ6XH2/ reporting anything interesting on the electrical measurement cluster."
Merged into DEV #1057 @MattWestb thanks for the help..!
@mitaka Just to clarify, did the quirk for TS011F in PR #1057 resolve the missing sensors or attributes?
Hello,
Currently using zha-quirks version 0.0.62 and homeassistant version 2021.10.5. The smartenergy_metering sensor is still showing unavailable but there is a new entity smartenergy_metering_summation_delivered which is showing something like the total used energy.
@mitaka
The support for TS011F is still in DEV.
@mitaka Just to clarify, did the quirk for TS011F in PR #1057 resolve the missing sensors or attributes?
@Hedda Not missing sensors. But value corrections and support for power state.
Hi,
I've just updated to Home Assistant Core version core-2021.11.0b0 and zha-device-handlers version 0.0.63. Mine version of the device is _TZ3000_cphmq0q7.
I can see rms_voltage and rms_current in Home Assistant interface. But reported values are wrong. Voltage is constantly 0.2V when real voltage is around 220V. Current with 6-8W load shows 62A.
By the way, is someone managed to change value of an attribute power_on_state (id: 0x8002) of TuyaZBOnOffRestorePowerCluster via Home Assistant interface?
@PlusPlus-ua there is no new zha-quirks release as of yet yet that contain https://github.com/zigpy/zha-device-handlers/pull/1107 (also see see https://github.com/zigpy/zha-device-handlers/issues/1108 for TS011F RMS current)
@PlusPlus-ua there is no new zha-quirks release as of yet yet that contain #1107 (also see see #1108 for TS011F RMS current)
It seems that this specific model that I have (_TZ3000_cphmq0q7
) still doesn't report correct voltage (as described by @PlusPlus-ua , it's 100 times lower than what it should be and current is 1000 times higher than what it is).
I guess we'll need to split the quirks between the various models :/
Referring to this one: #1107 where the author did remove the previous voltage correction to add the current one, with a screenshot attesting the values are now right for them.
Hi All,
Bought a Smartplug from ALI TS011F by _TZ3000_ew3ldmgx
HA added 1 switch and 3 sensors:
switch.tz3000_ew3ldmgx_ts011f_bb1466fe_on_off "SWITCH" sensor.tz3000_ew3ldmgx_ts011f_bb1466fe_electrical_measurement "192 W" sensor.tz3000_ew3ldmgx_ts011f_bb1466fe_smartenergy_metering "UNKNOWN"
Describe the solution you'd like The "smartenergy_metering" is not working. It should show the KwH On other forums there talking it could be a TS0121 thats advertises wrong. Also Zigbee2MQTT supports this Plug with metering.
Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line.
LOG