I saw Rave’s thread in Smartthings forum. I’m interested in what gateway sends to HASS. I don’t have zigbee plug and can’t test. But add additional temp sensor should be easy.
I updated your component and now in log:
17-04-11 18:29:44 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
result = next(coro)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 120, in _async_setup_platform
self.hass, self.config, self.domain, platform_type)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/setup.py", line 238, in async_prepare_setup_platform
platform = loader.get_platform(domain, platform_name)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/loader.py", line 103, in get_platform
return get_component(PLATFORM_FORMAT.format(domain, platform))
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/loader.py", line 141, in get_component
module = importlib.import_module(path)
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1467, in exec_module
File "<frozen importlib._bootstrap>", line 1572, in get_code
File "<frozen importlib._bootstrap>", line 1532, in source_to_code
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/homeassistant/.homeassistant/custom_components/sensor/xiaomi.py", line 27
add_devices(devices)
^
SyntaxError: invalid syntax
Any solution?
Fixed now…
Now is:
17-04-11 18:56:40 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform xiaomi
Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 153, in _async_setup_platform
entity_platform.schedule_add_entities, discovery_info
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/sensor/xiaomi.py", line 23, in setup_platform
devices.append(XiaomiSensor(device, 'Temperature', 'temperature', gateway))
File "/home/homeassistant/.homeassistant/custom_components/sensor/xiaomi.py", line 38, in __init__
XiaomiDevice.__init__(self, device, name, xiaomi_hub)
File "/home/homeassistant/.homeassistant/custom_components/xiaomi.py", line 396, in __init__
self.parse_voltage(device['data'])
File "/home/homeassistant/.homeassistant/custom_components/xiaomi.py", line 428, in parse_voltage
voltage = min(voltage, max_voltage)
NameError: name 'max_voltage' is not defined
Sorry for that. Fixed now
Thanks. Now is working but battery level in my sensors dropped from 65 to 35%. Strange.
I have a different method of calculating the battery state, but I am not sure if that’s correct.
Have you watched the battery state over time? Is it decreasing as expected?
I am expecting the voltage to decrease when battery level decreases.
https://github.com/Danielhiversen/homeassistant/blob/master/components/xiaomi.py#L430
I bought the sensors a month ago so the batteries should be almost full. From where we can monitor batteries levels most of the time they at 65% (strange all have the same level) sometimes one jumped to 63% and the other to 67% but always back to 65%.
It’s very much possible that the reported voltage does not correspond to the real voltage of the battery.
Unless you measure the battery and compare the measured value to the reported value you can’t know whether you got drained batteries, wrong algorithm for calculation, or simply incorrect measure.
@Danielhiversen Your algorithm looks reasonable. It’s not known, however, whether at 2.8V the sensor will drop or continue working until the voltage drops to 2V.
Hi Daniel. Here is different view on battery level calculation https://github.com/lunarok/jeedom_xiaomihome/pull/16
I’ve tested new illumination sensor a little. If illumination is not increasing gateway will update data only in one hour. Need to implement sensor update more frequently.
Mysensors uses the same Formula. Except that you never get a coin cell charged with 3300 better use 3200 and be happy when you got one which was 3250 or higher. the MinVolt depends on the Sensors capabilities, as it can still be functional with 2200. The Xiaomi Batteries came rather weak charged i guess the coin cells spend already quite a bit time in the warehouse.
Hey, quick question, is temperature sensor support in the pipeline? Would be cool to monitor the temp in my house. Also, the page describing how to get the key from the Gateway is entirely in Chinese which I don’t know even a little, and running it through Translate doesn’t produce something understandable for me too. Is there a quick English guide somewhere I can follow to get the key?
The temperature/humidity sensor (the original one - I think there may be another type now) has been working since at least the February 6 release.
The information you need for getting the key translates ok in Chrome. The screenshots obviously don’t but the menu positions are the same. Keep in mind that page can sometimes take ages to load.
Here’s the Chrome translations for the steps you need. It’s only really 5 you need unless you have multiple gateways.
- Tap the upper right corner of the screen
- Click on
- Press the bottom of the screen to open the developer mode
- Click LAN Protocol
- Open the LAN protocol and remember the password. This case is 1234567890123456
- Click Gateway Information
- Record the mac address. In this case, the corresponding mac is followed by 64: 09: 80: 2D: A3: CA
in what is different?
I think I may have been wrong. They’re being advertised as “Original” and “New” but I can’t see a difference.
Oh cool, thanks! I just ordered this one: http://s.aliexpress.com/zUBrY7Jj
And thanks for the steps. Still not entirely clear though, is the LAN password the key I need to use in configuration.yaml? Or do I need those two pieces of information to generate a key or something?
Yep that’s the one I’ve got.
The key is the gateway key you get from the Mi Home app from step 5.
You’ll have already given the gateway your WiFi passkey via the Mi Home app (you set the gateway up as per the Mi Home app instructions it’s just you don’t have the app do anything…or you can if you want to - I have two switches, one controls HA automations and the other Mi Home automations - HA is vastly superior though).
If there’s multiple wifi networks you need the sid but otherwise just leave it blank.
As usual with yaml watch for spaces and tabs (I run mine through this http://codebeautify.org/yaml-validator).
xiaomi:
gateways:
- sid:
key: 'insertkeyhere'
is someone using a cube to control yeelights brightness ?
All my attempts fail miserably :’(
You can use something similar to @Danielhiversen config:
Just replace the volume with brightness and you should be good to go.