Closed peterhoe closed 2 years ago
I'm also playing around with a TH10 and the new MS01 soil moisture sensor (having hoped it would maybe use the existing humidity sensor), but can't seem to get it to work. Will it need a new development for extending the available sensors to include moisture?
Thank you!
I have been playing around with the MS01 as well but I can’t pull any reading to HA. It would be very nice if this could be added. Would save the world probably quite some water 😁 Used TH10 + ms01
This my debug log. I can’t find any differences between various set-ups.
Sensor MS01:
2021-12-25 02:48:42 DEBUG main 1000bcd3c2 == Init | {'uiid': 15, 'extra': {'manufacturer': 'SONOFF', 'model': 'TH10', 'sw_version': 'PSA-BHA-GL v3.5.0'}, 'params': {'bindInfos': {'gaction': ['...', '...'], 'alexa': ['...']}, 'version': 8, 'sledOnline': 'on', 'init': 1, 'switch': 'on', 'fwVersion': '3.5.0', 'rssi': -42, 'staMac': '...', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'deviceType': 'normal', 'mainSwitch': 'on', 'sensorType': 'MS01', 'currentHumidity': '25', 'currentTemperature': 'unavailable', 'timers': [{'mId': '...', 'type': 'repeat', 'at': '0 3 * * 0,1,2,3,4,5,6', 'coolkit_timer_type': 'repeat', 'enabled': 1, 'do': {'switch': 'off', 'mainSwitch': 'off'}}], 'only_device': {'ota': 'success'}, 'ssid': '...', 'bssid': '...', 'cloud': 'online'}}
2021-12-25 02:48:43 DEBUG sonoff_local 1000bcd3c2 <= Local1 | {'mainSwitch': 'on', 'deviceType': 'normal', 'switch': 'on', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'sledOnline': 'on', 'sensorType': 'MS01', 'currentHumidity': '25', 'currentTemperature': 'unavailable', 'ssid': '...', 'bssid': '...'} | 22
Sensor AM2301:
2021-12-25 03:34:11 DEBUG main 1000bcd3c2 == Init | {'uiid': 15, 'extra': {'manufacturer': 'SONOFF', 'model': 'TH10', 'sw_version': 'PSA-BHA-GL v3.5.0'}, 'params': {'bindInfos': {'gaction': ['...', '...'], 'alexa': ['...']}, 'version': 8, 'sledOnline': 'on', 'init': 1, 'switch': 'on', 'fwVersion': '3.5.0', 'rssi': -42, 'staMac': '...', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'deviceType': 'normal', 'mainSwitch': 'on', 'sensorType': 'AM2301', 'currentHumidity': '65', 'currentTemperature': '23.9', 'timers': [{'mId': '...', 'type': 'repeat', 'at': '0 3 * * 0,1,2,3,4,5,6', 'coolkit_timer_type': 'repeat', 'enabled': 1, 'do': {'switch': 'off', 'mainSwitch': 'off'}}], 'only_device': {'ota': 'success'}, 'ssid': '...', 'bssid': '...', 'cloud': 'online'}}
2021-12-25 03:34:12 DEBUG sonoff_local 1000bcd3c2 <= Local1 | {'mainSwitch': 'on', 'deviceType': 'normal', 'switch': 'on', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'sledOnline': 'on', 'sensorType': 'AM2301', 'currentHumidity': '64', 'currentTemperature': '24.0', 'ssid': '...', 'bssid': '...'} | 7
Sensor DS18B20:
2021-12-25 04:15:17 DEBUG main 1000bedaf2 == Init | {'uiid': 15, 'extra': {'manufacturer': 'SONOFF', 'model': 'TH16', 'sw_version': 'PSA-BHA-GL v3.5.0'}, 'params': {'bindInfos': {'gaction': ['...', '...'], 'alexa': ['...']}, 'version': 8, 'sledOnline': 'on', 'init': 1, 'switch': 'off', 'fwVersion': '3.5.0', 'rssi': -24, 'staMac': '...', 'startup': 'off', 'pulse': 'off', 'pulseWidth': 500, 'sensorType': 'DS18B20', 'currentHumidity': 'unavailable', 'currentTemperature': '12.9', 'mainSwitch': '', 'deviceType': 'normal', 'only_device': {'ota': 'success'}, 'ssid': '...', 'bssid': '...', 'cloud': 'online'}}
It seems that in case of MS01 the attributes are not added. I have explored sensor.py but I haven’t found the clue. When using the MS01 the attributes temperature and humidity are not available. But when the AM2301 is connected it comes back after restart. Tested this twice. Swapping one the AM2301 to MS01 and back make the attributes and values to disappear and appear again. Why is that? I need a few clues or pointers where to look to resolve this.. Alexxit?
I have resolved it. Works for me now. I have sent the info to Alex.
Actually I think it’s/was a bug
Tried to get soil humidity data but without any success too (TH16+MS01).
me 2, why MS01+TH16 dont work? :(
share your solution my friend :)
In the following function in cloud.py there is a mistake. Replace the existing 'def fix_attrs(deviceid: str, state: dict)' by this one and let me know if it worked for you: ""
try:
# battery_level is common name for battery attribute
if 'battery' in state:
state[ATTR_BATTERY_LEVEL] = state['battery']
for k in ('power', 'voltage', 'current'):
if k in state:
state[k] = float(state[k])
# zigbee device
if deviceid.startswith('a4'):
for k in ('temperature', 'humidity'):
if k in state:
state[k] = int(state[k]) / 100.0
# "unavailable" in state creates a fault
if state['currentHumidity'] == 'unavailable':
_LOGGER.debug(f"TH humidity: unavailable")
elif 'currentHumidity' in state:
state['humidity'] = float(state['currentHumidity'])
_LOGGER.debug(f"TH humidity: {state['humidity']}")
if state['currentTemperature'] == 'unavailable':
_LOGGER.debug(f"TH temperature: unavailable")
elif 'currentTemperature' in state:
state['temperature'] = float(state['currentTemperature'])
_LOGGER.debug(f"TH temperature: {state['temperature']}")
except:
pass
""
Good luck
In the following function in cloud.py there is a mistake. Replace the existing 'def fix_attrs(deviceid: str, state: dict)' by this one and let me know if it worked for you: ""
# "unavailable" in state creates a fault if state['currentHumidity'] == 'unavailable': _LOGGER.debug(f"TH humidity: unavailable") elif 'currentHumidity' in state: state['humidity'] = float(state['currentHumidity']) _LOGGER.debug(f"TH humidity: {state['humidity']}") if state['currentTemperature'] == 'unavailable': _LOGGER.debug(f"TH temperature: unavailable") elif 'currentTemperature' in state: state['temperature'] = float(state['currentTemperature']) _LOGGER.debug(f"TH temperature: {state['temperature']}")
Thanks a lot - yes, this part helps!
Great to hear !
Also worked for me thank you very much :-)
Hi, i changed my code for, custom_components/sonoff/sonoff_cloud.py
def fix_attrs(deviceid: str, state: dict):
"""
- Sonoff TH `currentTemperature: "24.7"`
- Sonoff TH `currentTemperature: "unavailable"`
- Sonoff ZigBee: `temperature: "2096"`
- Sonoff SC: `temperature: 23`
- Sonoff POW: `power: "12.78"`
"""
try:
# battery_level is common name for battery attribute
if 'battery' in state:
state[ATTR_BATTERY_LEVEL] = state['battery']
for k in ('power', 'voltage', 'current'):
if k in state:
state[k] = float(state[k])
# zigbee device
if deviceid.startswith('a4'):
for k in ('temperature', 'humidity'):
if k in state:
state[k] = int(state[k]) / 100.0
# "unavailable" in state creates a fault
if state['currentHumidity'] == 'unavailable':
_LOGGER.debug(f"TH humidity: unavailable")
elif 'currentHumidity' in state:
state['humidity'] = float(state['currentHumidity'])
_LOGGER.debug(f"TH humidity: {state['humidity']}")
if state['currentTemperature'] == 'unavailable':
_LOGGER.debug(f"TH temperature: unavailable")
elif 'currentTemperature' in state:
state['temperature'] = float(state['currentTemperature'])
_LOGGER.debug(f"TH temperature: {state['temperature']}")
except:
pass
add: configuration.yaml
sonoff:
username: x@x.com
password: x
force_update: [temperature, power]
scan_interval: "00:01:00"
reload: always
sensors: [temperature, humidity, power, current, voltage]
validate config, reboot and not working :(
You just did a copy-paste? And not working means the sensor doesn´t appear? or the sensor appears but doesnt give values?
You just did a copy-paste? And not working means the sensor doesn´t appear? or the sensor appears but doesnt give values?
the sensor doesn´t appear, i just copy-paste
You just did a copy-paste? And not working means the sensor doesn´t appear? or the sensor appears but doesnt give values?
the sensor doesn´t appear, i just copy-paste
Só there could a number of issues now. First do you use ewelink and does it exist there? Do you use other Sonoff items and do they appear? You have Sonoff Lan intergretion. Seems obvious..
If all are yes set debug to true in your config and find the entity in the initiation of the debug list first.
In the following function in cloud.py there is a mistake. Replace the existing 'def fix_attrs(deviceid: str, state: dict)' by this one and let me know if it worked for you: ""
try: # battery_level is common name for battery attribute if 'battery' in state: state[ATTR_BATTERY_LEVEL] = state['battery'] for k in ('power', 'voltage', 'current'): if k in state: state[k] = float(state[k]) # zigbee device if deviceid.startswith('a4'): for k in ('temperature', 'humidity'): if k in state: state[k] = int(state[k]) / 100.0 # "unavailable" in state creates a fault if state['currentHumidity'] == 'unavailable': _LOGGER.debug(f"TH humidity: unavailable") elif 'currentHumidity' in state: state['humidity'] = float(state['currentHumidity']) _LOGGER.debug(f"TH humidity: {state['humidity']}") if state['currentTemperature'] == 'unavailable': _LOGGER.debug(f"TH temperature: unavailable") elif 'currentTemperature' in state: state['temperature'] = float(state['currentTemperature']) _LOGGER.debug(f"TH temperature: {state['temperature']}") except: pass
""
Good luck
Work great, Thank you !
Fixed in latest master-version. Will be in next release. https://github.com/AlexxIT/SonoffLAN/releases
I'm having some issues with getting all values from MS01 on THR316 in InfluxDB.
While ewelink app csv export shows all values each hour, I have only a few values imported in influxdb (like one every couple hours). CSV exports included for both ewelink, influx. Also diagnostics
config_entry-sonoff-ee84b0b81fea4318e6fa8864da266746.json.txt
thanks
Am having some troubles integrating the Sonoff MS01 soil moisture sensor using a TH10
Sonoff LAN v2.4.6
Works fine with AM2301 temp / humidity sensor
Hass State attributes with AM2301 manufacturer: SONOFF model: TH10 sw_version: PSA-BHA-GL v3.5.0 cloud: online rssi: -41 local: online humidity: 29 temperature: 33.5 friendly_name: irr-balcony-soil
MS01 with TH10 will not pull in humidity sensor data to Haasio, however in Sonoff debug i see a value for currentHumidity although currentTemperature is listed as unavailable
Hass State attributes with MS01 manufacturer: SONOFF model: TH10 sw_version: PSA-BHA-GL v3.5.0 cloud: online rssi: -36 local: online friendly_name: irr-balcony-soil