Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

And again about refresh interval (correct data appears in debug but does not work) #582

Closed
ihor-chaban opened this issue Aug 25, 2021 · 2 comments

Comments

@ihor-chaban
Copy link

ihor-chaban commented Aug 25, 2021

Hi,
I read through this issue #14 and I have the exact same case now.
The data does not refresh from my TH16 R2 device, however, the scan_interval is set to 1 minute.

But I found one very interesting thing - when enabled debug mode, all fresh data appears there with the perfect interval of 1 minute. But in this case why it does not come to Home Assistant properly?

Also, noted that the proper attributes in debug logs are called currentTemperature and currentHumidity, maybe thats the point? Because if the correct data appears in debug but does not work in app it looks like a code issue. Maybe they changed attribute names in the latest firmware? I see that in code it uses correct attribute names, but why it is not working then?

./custom_components/sonoff/__init__.py:        # fix cloud attrs like currentTemperature and currentHumidity
./custom_components/sonoff/sonoff_local.py:            if 'currentTemperature' in state:
./custom_components/sonoff/sonoff_local.py:                    state['temperature'] = float(state['currentTemperature'])
./custom_components/sonoff/sonoff_cloud.py:    - Sonoff TH `currentTemperature: "24.7"`
./custom_components/sonoff/sonoff_cloud.py:    - Sonoff TH `currentTemperature: "unavailable"`
./custom_components/sonoff/sonoff_cloud.py:        if 'currentTemperature' in state:
./custom_components/sonoff/sonoff_cloud.py:            state['temperature'] = float(state['currentTemperature'])

My TH is on 3.5.0 firmware now.
Attaching my debug logs and configuration below.

debug output:

2021-08-25 16:11:16  DEBUG    main          SysInfo: {'version': '2021.8.8', 'dev': False, 'hassio': False, 'virtualenv': False, 'python_version': '3.9.6', 'docker': True, 'user': 'root', 'arch': 'armv7l', 'os_name': 'Linux', 'os_version': '5.10.52-v7l+'}
2021-08-25 16:11:16  DEBUG    main          AUTO mode start
2021-08-25 16:11:19  DEBUG    sonoff_cloud  3 devices loaded from the Cloud Server
2021-08-25 16:11:19  DEBUG    main          Init force_update for attributes: {'humidity', 'temperature'}
2021-08-25 16:11:19  DEBUG    main          Init auto sensors for: ['temperature', 'humidity']
2021-08-25 16:11:19  DEBUG    main          10008d1d34 == Init   | {'uiid': 15, 'extra': {'manufacturer': 'SONOFF', 'model': 'TH16', 'sw_version': 'PSA-BHA-GL v3.5.0'}, 'params': {'version': 8, 'sledOnline': 'on', 'init': 1, 'switch': 'off', 'fwVersion': '3.5.0', 'rssi': -71, 'staMac': '...', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'mainSwitch': 'off', 'deviceType': 'normal', 'targets': [{'targetHigh': '23.0', 'reaction': {'switch': 'off'}}, {'targetLow': '23.0', 'reaction': {'switch': 'on'}}], 'sensorType': 'AM2301', 'currentHumidity': '59', 'currentTemperature': '24.8', 'timers': [{'mId': '...', 'type': 'once', 'at': '2021-08-21T22:16:00.724Z', 'coolkit_timer_type': 'delay', 'enabled': 1, 'do': {'switch': 'off', 'mainSwitch': 'off'}, 'period': '60'}], 'bindInfos': {'scene': 2}, 'only_device': {'ota': 'success'}, 'ssid': '...', 'bssid': '...', 'cloud': 'online'}}
2021-08-25 16:11:19  DEBUG    main          1000c7a2f5 == Init   | {'uiid': 1, 'extra': {'manufacturer': 'SONOFF', 'model': 'BASIC', 'sw_version': 'PSF-B01-GL v3.5.1'}, 'params': {'version': 8, 'sledOnline': 'on', 'switch': 'on', 'fwVersion': '3.5.1', 'rssi': -51, 'staMac': '...', 'startup': 'stay', 'init': 1, 'pulse': 'off', 'pulseWidth': 500, 'timers': [{'mId': '...', 'type': 'once', 'at': '2021-06-18T23:00:00.392Z', 'coolkit_timer_type': 'delay', 'enabled': 1, 'do': {'switch': 'off'}, 'period': '5'}], 'only_device': {'ota': 'success'}, 'ssid': '...', 'bssid': '...', 'bindInfos': {'scene': 0}, 'cloud': 'online'}}
2021-08-25 16:11:19  DEBUG    main          1000c74d71 == Init   | {'uiid': 1, 'extra': {'manufacturer': 'SONOFF', 'model': 'BASIC', 'sw_version': 'PSF-B01-GL v3.5.1'}, 'params': {'version': 8, 'sledOnline': 'on', 'switch': 'off', 'fwVersion': '3.5.1', 'rssi': -66, 'staMac': '...', 'startup': 'off', 'init': 1, 'pulse': 'off', 'pulseWidth': 500, 'only_device': {'ota': 'success'}, 'ssid': '...', 'bssid': '...', 'bindInfos': {'scene': 2}, 'cloud': 'online'}}
2021-08-25 16:11:19  DEBUG    sonoff_local  1000c74d71 <= Local1 | {'switch': 'off', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'rssi': -66, 'ssid': '...', 'bssid': '...'} | 34
2021-08-25 16:11:19  DEBUG    sonoff_local  1000c7a2f5 <= Local1 | {'switch': 'on', 'startup': 'stay', 'pulse': 'off', 'sledOnline': 'on', 'pulseWidth': 500, 'rssi': -51, 'ssid': '...', 'bssid': '...'} | 24
2021-08-25 16:11:19  DEBUG    sonoff_local  10008d1d34 <= Local1 | {'mainSwitch': 'off', 'deviceType': 'normal', 'switch': 'off', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'sledOnline': 'on', 'sensorType': 'AM2301', 'currentHumidity': '57', 'currentTemperature': '25.1', 'ssid': '...', 'bssid': '...'} | 26400
2021-08-25 16:11:19  DEBUG    sonoff_cloud  Cloud init: {'error': 0, 'apikey': '...', 'config': {'hb': 1, 'hbInterval': 145}, 'sequence': '1629897079678'}
2021-08-25 16:12:19  DEBUG    switch        Refresh device state 10008d1d34
2021-08-25 16:12:19  DEBUG    sonoff_local  10008d1d34 => Local4 | {'sledonline': 'on'} <= {'seq': 26401, 'sequence': '1629897139320', 'error': 0}
2021-08-25 16:12:19  DEBUG    sonoff_local  10008d1d34 <= Local3 | {'mainSwitch': 'off', 'deviceType': 'normal', 'switch': 'off', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'sledOnline': 'on', 'sensorType': 'AM2301', 'currentHumidity': '57', 'currentTemperature': '25.1', 'ssid': '...', 'bssid': '...'} | 26401
2021-08-25 16:12:19  DEBUG    sonoff_cloud  10008d1d34 <= Cloud3 | {'action': 'update', 'deviceid': '10008d1d34', 'apikey': '...', 'userAgent': 'device', 'sequence': '1629897139320', 'params': {'sledOnline': 'on'}, 'from': 'device', 'seq': '26401'}
2021-08-25 16:12:19  DEBUG    sonoff_main   Skip update with same sequence
2021-08-25 16:13:19  DEBUG    switch        Refresh device state 10008d1d34
2021-08-25 16:13:19  DEBUG    sonoff_local  10008d1d34 => Local4 | {'sledonline': 'on'} <= {'seq': 26402, 'sequence': '1629897199323', 'error': 0}
2021-08-25 16:13:19  DEBUG    sonoff_local  10008d1d34 <= Local3 | {'mainSwitch': 'off', 'deviceType': 'normal', 'switch': 'off', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'sledOnline': 'on', 'sensorType': 'AM2301', 'currentHumidity': '57', 'currentTemperature': '25.1', 'ssid': '...', 'bssid': '...'} | 26402
2021-08-25 16:13:19  DEBUG    sonoff_cloud  10008d1d34 <= Cloud3 | {'action': 'update', 'deviceid': '10008d1d34', 'apikey': '...', 'userAgent': 'device', 'sequence': '1629897199323', 'params': {'sledOnline': 'on'}, 'from': 'device', 'seq': '26402'}
2021-08-25 16:13:19  DEBUG    sonoff_main   Skip update with same sequence

configuration.yaml:

sonoff:
  username: my-email
  password: my-password
  force_update: [temperature, humidity]
  scan_interval: '00:01:00'
  sensors: [temperature, humidity]
  reload: always
  debug: true

sensor:
  - platform: template
    sensors:
      temperature:
        friendly_name: 'Room Temperature'
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('switch.sonoff_10008d1d34', 'temperature') }}"
      humidity:
        friendly_name: 'Room Humidity'
        unit_of_measurement: '%'
        value_template: "{{ state_attr('switch.sonoff_10008d1d34', 'humidity') }}"
@ihor-chaban
Copy link
Author

Ok, I see you wrote this was fixed in master.
But I re-installed the component from master and it still does not work...

@ihor-chaban
Copy link
Author

Dunno what was the reason, but it is working from master now. Thank you for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant