I’m currently developing the xiaomi module to integrate it into v4. For now, I want to have the minimum functionality (at this point I can retrieve the devices, including those for temperature and those for humidity).
I want to modify the device_feature value of my device. For this, I retrieve index which is the device number (among the list of xiaomi devices), then features for the features attribute (which lists all the features such as temperatures, humidity, …) and then I have data-key which allows me to retrieve the feature number to get the right one. Then I want to modify field which is therefore the ‹ name › column and then I finish by setting the value with the new value.
Why doesn’t it work? (front-end error)
Uncaught ReferenceError: xiaomiCapteurTemperature is not defined
When reading quickly, I would say you have a scope issue.
Your variable is declared either in the if or in the else. Lines 75 and 87.
By line 95, your variable is undefined as it is out of scope of your conditions.
However, a small remark, don’t use [value.getAttribute('data-key')]:, that’s not good React practice at all ^^
I would advise you to create sub-components and manage this locally within the components, as I have done in the Z-Wave service for example, example here =>
I just opened a PR, a question about the door detectors. How do you handle the fact that the detector can oscillate between 0 and 1? Isn’t that bothersome?
Well, normally if the two devices are next to each other they should be 1, but if they change state (at the limit of detectability, it could mess up, right?) Basically, it has trouble detecting them, so it randomly switches from 0 to 1 and potentially quickly.
@pierre-gilles I wanted to know what you think about this. I have therefore merged the different possible Xiaomi sensors. However, when we take the example of the gateway or even the Xiaomi lamps, I think it is still important to separate these elements, don’t you think?
I agree, we can have multiple tabs, then we can group all the sensors together in my opinion.
However, these views are only the « what the service sees » views, but we need another view that groups all the devices « Gladys side » like on the Z-Wave service.