I’m very sorry for asking this silly question but I still cannot figure out what the key is. I followed the steps here http://bbs.xiaomi.cn/t-13198850:
8 Write down the password for the fifth step and the MAC address that you noted in step 7, both of which will be used as the gateway name and password and will be configured into the config.json file at a later raspberry pie. Now, the gateway information to complete the steps to complete friends.
@Danielhiversen: There is a missing closing bracket in the binary_sensor/xiaomi.py file in line 87. This is causing an error and the binary_sensors don’t show up in HA.
open the gateway app
press the 3 dots icon (top right)
press about
press local area network communication protocol
enable (top option)
the password is what you put for the key in your config.yaml
(should be 16 digit)
@Danielhiversen I use your fork and today when automation tried to turn on gateway light errors appear in log:
17-04-23 21:36:42 ERROR (Thread-7) [custom_components.xiaomi] Non matching response. Expecting read_ack, but got write_ack
17-04-23 21:36:42 ERROR (Thread-4) [custom_components.xiaomi] Non matching response. Expecting write_ack, but got read_ack
17-04-23 21:36:42 ERROR (Thread-7) [custom_components.xiaomi] No data in response from hub None
17-04-23 21:36:42 ERROR (Thread-4) [custom_components.xiaomi] No data in response from hub None
There were a few errors on something like inconsistent use of tab and space
I fixed those but now I get this:
Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity_component.py", line 155, in _async_setup_platform
entity_platform.schedule_add_entities, discovery_info
File "uvloop/future.pyx", line 230, in __iter__ (uvloop/loop.c:110600)
File "uvloop/future.pyx", line 432, in uvloop.loop.BaseTask._fast_wakeup (uvloop/loop.c:113980)
File "uvloop/future.pyx", line 101, in uvloop.loop.BaseFuture._result_impl (uvloop/loop.c:108900)
File "/usr/local/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/switch/xiaomi.py", line 31, in setup_platform
devices.append(XiaomiGenericSwitch(device, "Plug", 'status', gateway))
File "/config/custom_components/switch/xiaomi.py", line 50, in __init__
XiaomiDevice.__init__(self, device, name, xiaomi_hub)
File "/config/custom_components/xiaomi.py", line 446, in __init__
self.parse_data(device['data'])
File "/config/custom_components/switch/xiaomi.py", line 102, in parse_data
self._power_consumed = (int(data[POWER_CONSUMED])/1000)+' kWh'
TypeError: unsupported operand type(s) for +: 'float' and 'str'
Also I think I would prefer the number without the unit of measure in the attribute.
It is much easier to work with a number than to extract it from the string.
Make sure the unit is clear from the documentation.
Like you do with battery level as attribute. it does not have the % at the end.
But it is up to you.
I will probably change it into a template sensor with a Unit Of Measure attribute anyway so it can be plotted.
Strings won’t plot.
does anyone have an example of automation using the ringtone (alarm) function? I can’t figure it out what to put in the yaml.
also, can’t seem to be able to trigger action based on the motion sensor. I’ve spent 2 hours on it. Can anyone help?
I’ve tried using to: 'on' as below, also tried to: 'motion' and also tried state: 'on'
- alias: Turn on light on motion
trigger:
platform: state
entity_id: binary_sensor.motion_sensor_158d00011xxxx
to: 'on'
action:
service: light.turn_on
entity_id: light.gateway_light_f0b429cxxx