Can someone explain BroadLink A1 Values?

What is the 0/1 I see on Noise / Air Quality / Light ?
is there no range?
is it comparable to the text values in the e-control App ?

1 Like

The above would be assuming the data is correct…

After showing “reasonable info” before - the numbers seem to go crazy high (On the left is the information from the e-control app, on the right - info showing on HA

I am not sure if there is a conversion problem or the connection between A1 and HA was lost?
(nothing related on the log it seems)

The numbers converted to text can be found here
https://github.com/mjg59/python-broadlink/blob/master/broadlink/init.py#L383

Hi. I also have the same problem. Installation was done on a raspberry. I do not understand why, but it works fine for a few hours and then abnormal values start to appear.It only gets fine again by restarting hass.
Edit: i found the Daniel reply in another thread.

I have just added som data validation, so hope you can help test this: Broadlink RM-PRO and TC2 switch

I see there is MP1 support coming too ! I’m so waiting for that.

Regarding your first answer on the translation - I wonder why not to show this text directly in the value showing up in HA (do the translation in the code rather than leave the numbers) - it would be much more user friendly (it’s not like you can do much with the numbers as they are…)

Regarding the abnormal numbers… I would love to help you test but I am not sure how to do that (I don’t have a developer version setup and I am not sure what to run on my pi to provide you with the data…)

also please note in the picture I had above (showing again here:)

Note that the abnormal measurement was taken 5 hours before the screen capture - than it was stuck like that until (like @Paulo106 said) I restarted HA - that value remained the same…

so in this particular case it’s not like the A1 consistently started broadcasting abnormal numbers…

So for some reason - I did not see any errors in the text but also it seems that no other measurement was taken…

also it’s not a hardware issue because I saw the stats changing within the BroadLink app on my smartphone…

I tried disconnecting the A1 and reconnecting - but that did not help the data showing on HA.

Maybe it’s a cache issue, not cleaning some variable or something? I am not sure it’s something that I can verify by running your code outside HA because it may be something in particular instance running with Ha.

I would suggest that you flood the code with “Debug” prints on every point and provide the code maybe as a custom component - that way I could run it on my PI without developer env settings and provide you with a full log of the debug messages as soon as it happens (assuming it will…)

let me know if you want to try that either here or via direct message :wink:
I would love to help any way that I can!

The easy answer, is that I made the component and I prefer numbers :slight_smile:
I think number is better since it shows a graph with the change during the day. It is possible to change from number to text with a template sensor. It is posted a description for that somewhere in the forum.

This is not high on my priority list, so I will probably not do much to fix it. So someone with the problem have to make an effort in fixing it.

It is supported by the library, but someone have to add support for it in HA. It should be quite easy, just copy and modify how I have made support for the other switches

Have you enabled logging for the Broadlink component? I would guess it is a connection problem, if it it is stuck at one level.

I have… but nothing is showing so far (I can not expect when the device would switch to the abnormal numbers so I don’t know if it’s working).

I put all the sensors on info logging which should dump everything if and when.

I am also trying to play with the code in a custom component version but for some reason it’s not showing me any log data that I am trying to add…

Since you said “someone with the problem have to make an effort in fixing it” - I am trying but I don’t know how deep it will take me and if my skills are sufficient.

I am also trying to create another sensor mode which is more descriptive in addition to the number since I see your point about the graph but still - having the text would help in creating text automation for tts / alexa. (I guess I could also go with a sensor template but I want to see if I can get it from the code).

** if anyone knows why my logging attempts in the custom component code are not showing - please drop me a line.

Do you use custom_components.switch.broadlink: debug ?
(or sensor instead of switch if it is the sensor you want to debug)

now I am :slight_smile:

thanks

Made some progress…
captured the period in which abnormal numbers started and returned to normal, Not sure why though.

Maybe I should add some log to the “broadlink” code which is imported in the BroadlinkData(object)… will the logging work from that code as well? Idea’s before I pick this up again tomorrow?

this is from my log:

https://hastebin.com/ewumadozod.css

@Danielhiversen

after running your updated code for a few days and adding some debug messages of my own…
at some point my log start’s looking like this:

https://hastebin.com/xevawodeve.sql

the problem now is mainly with the RM2 and it seems the A1 is more stable (but I can’t be sure it won’t happen later at some point as it has in the past…)

see’s like that data object stops reacting at some point (for very long periods of time)…

I am not sure I follow the code 100%, but wouldn’t it be interesting to try and re"auth" the device from time to time when an error occurs or something? (that step that only happens on initialization…)

Latest log entries from the past 10 hours or so and some new logging lines I added
https://hastebin.com/awicezetol.cs
At some point along the way Broadlinkdata._update is getting a broken “self” and for “check_sensors_raw” – “data” is None which is not handled by the try – except and from that point the HA sensor component is useless (keeps showing same value it had from before the data was corrupted).

I don’t know how to investigate further why the data becomes corrupt :frowning: solving that would be best
For now I added

data = self._device.check_sensors_raw()
### New code starting here
_LOGGER.debug("%s retries to go", retry)
if (str(data)) == 'None':
   _LOGGER.debug("Data is None, Self is %s", str(self))
   self._auth()
   if retry > 1 :
	 self._update(retry-1)
   return

I’ll see how it works in the next few hours but any suggestion on following the root cause would be appreciated

We do that: core/homeassistant/components/sensor/broadlink.py at 58f813b518ebbf69453c80b35230cd3c1f54dc66 · home-assistant/core · GitHub

That seams to be an error caused by your modification

We already check if data is None: core/homeassistant/components/sensor/broadlink.py at 58f813b518ebbf69453c80b35230cd3c1f54dc66 · home-assistant/core · GitHub

That is correct… and it seems that you’ve been busy since I forked the code to my custom component last week :slight_smile:

that if that handles the “data = none” was not there at the time

I’ll update and see how it goes…

Hei @Danielhiversen, i am too new in this and i might need your help. I saw that you already transformed those 0/1 values from A1 to names …i saw that init.py doc. I really can’t figure out where should i place it…or what should i do with it. Thanks for doing that and thanks in advance for your answer :slight_smile:

Here is my configuration for Broadlink A1 showing text for noise, light and air quality:

# Broadlink A1
  - platform: broadlink
    host: 10.0.1.xxx
    mac: 'xx:xx:xx:xx:xx:xx'
    monitored_conditions:
      - temperature
      - humidity
      - air_quality
      - light
      - noise
  - platform: template
    sensors:
      a1air:
        friendly_name: Air Quality
        value_template: >-
          {% if is_state('sensor.broadlink_sensor_air_quality', '0') -%}
            excellent
          {%- elif is_state('sensor.broadlink_sensor_air_quality', '1') -%}
            good
          {%- elif is_state('sensor.broadlink_sensor_air_quality', '2') -%}
            normal
          {%- elif is_state('sensor.broadlink_sensor_air_quality', '3') -%}
            bad
          {%- else -%}
            unknown
          {%- endif %}
      a1light:
        friendly_name: Light
        value_template: >-
          {% if is_state('sensor.broadlink_sensor_light', '0') -%}
            dark
          {%- elif is_state('sensor.broadlink_sensor_light', '1') -%}
            dim
          {%- elif is_state('sensor.broadlink_sensor_light', '2') -%}
            normal
          {%- elif is_state('sensor.broadlink_sensor_light', '3') -%}
            bright
          {%- else -%}
            unknown
          {%- endif %}
      a1noise:
        friendly_name: Noise
        value_template: >-
          {% if is_state('sensor.broadlink_sensor_noise', '0') -%}
            quiet
          {%- elif is_state('sensor.broadlink_sensor_noise', '1') -%}
            normal
          {%- elif is_state('sensor.broadlink_sensor_noise', '2') -%}
            noisy
          {%- else -%}
            unknown
          {%- endif %}