will retry
I think I see the problem now.
You have given the mac address and not the sid.
If you run the latest version again, you should see something like ERROR … Unknown Xiaomi Gateway GATEWAY_SID
how to obtain the sid from the mac
from instructions
#12 characters sid can be obtained from the gateway's MAC address.
like this?/
xiaomi:
gateways:
- sid: f0b429cc0dd8
key: s0adr7t03s3xxxxx
Hi,
I have an automation in the Mi Home for the Brightness using the cube that when I rotate clockwise it turns the brightness up and anti-clockwise turns the brightness down. Does anyone know how can I reproduce that using automation in HA?
Thanks.
I do the same to set the volume of a media player: https://github.com/Danielhiversen/home-assistant_config/blob/master/automation/audio.yaml#L187
Ok,
I have a bigger problem now, after the code change, HASS is not starting … had to start it manually
pi@raspberrypi:~ $ sudo su -s /bin/bash hass
hass@raspberrypi:/home/pi$ source /srv/hass/hass_venv/bin/activate
(hass_venv) hass@raspberrypi:/home/pi$ hass
Config directory: /home/hass/.homeassistant
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeas sistant, service=turn_off>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeas sistant, service=turn_on>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeas sistant, service=toggle>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeas sistant, service=reload_core_config>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=persis tent_notification, service=create>
INFO:homeassistant.bootstrap:Home Assistant core initialized
INFO:homeassistant.loader:Loaded homematic from homeassistant.components.homemat ic
INFO:homeassistant.loader:Loaded frontend from homeassistant.components.frontend
INFO:homeassistant.loader:Loaded api from homeassistant.components.api
INFO:homeassistant.loader:Loaded http from homeassistant.components.http
INFO:homeassistant.loader:Loaded websocket_api from homeassistant.components.web socket_api
INFO:homeassistant.loader:Loaded input_boolean from homeassistant.components.inp ut_boolean
INFO:homeassistant.loader:Loaded microsoft_face from homeassistant.components.mi crosoft_face
INFO:homeassistant.loader:Loaded camera from homeassistant.components.camera
INFO:homeassistant.loader:Loaded zone from homeassistant.components.zone
INFO:homeassistant.loader:Loaded alexa from homeassistant.components.alexa
INFO:homeassistant.loader:Loaded netatmo from homeassistant.components.netatmo
INFO:homeassistant.loader:Loaded history from homeassistant.components.history
INFO:homeassistant.loader:Loaded recorder from homeassistant.components.recorder
INFO:homeassistant.loader:Loaded proximity from homeassistant.components.proximi ty
INFO:homeassistant.loader:Loaded device_tracker from homeassistant.components.de vice_tracker
INFO:homeassistant.loader:Loaded script from homeassistant.components.script
INFO:homeassistant.loader:Loaded group from homeassistant.components.group
INFO:homeassistant.loader:Loaded switch from homeassistant.components.switch
INFO:homeassistant.loader:Loaded logbook from homeassistant.components.logbook
INFO:homeassistant.loader:Loaded sensor from homeassistant.components.sensor
INFO:homeassistant.loader:Loaded updater from homeassistant.components.updater
INFO:homeassistant.loader:Loaded notify from homeassistant.components.notify
Traceback (most recent call last):
File "/srv/hass/hass_venv/bin/hass", line 11, in <module>
sys.exit(main())
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/__main__.p y", line 381, in main
exit_code = setup_and_run_hass(config_dir, args)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/__main__.p y", line 293, in setup_and_run_hass
log_rotate_days=args.log_rotate_days)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap. py", line 467, in from_config_file
hass.loop.run_until_complete(future)
File "/usr/lib/python3.4/asyncio/base_events.py", line 276, in run_until_compl ete
return future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap. py", line 458, in _async_init_from_config_file
config_path, hass, verbose, skip_pip, log_rotate_days)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap. py", line 500, in async_from_config_file
config_dict, hass, enable_log=False, skip_pip=skip_pip)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap. py", line 431, in async_from_config_dict
for domain in loader.load_order_components(components):
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/loader.py" , line 192, in load_order_components
key=lambda order: 'group' in order):
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/loader.py" , line 191, in <genexpr>
for component in components),
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/loader.py" , line 211, in load_order_component
return _load_order_component(comp_name, OrderedSet(), set())
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/loader.py" , line 220, in _load_order_component
component = get_component(comp_name)
File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/loader.py" , line 139, in get_component
module = importlib.import_module(path)
File "/srv/hass/hass_venv/lib/python3.4/importlib/__init__.py", line 109, in i mport_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/hass/.homeassistant/custom_components/xiaomi.py", line 136
continue
^
IndentationError: unexpected indent
I went to see line 136, but my knowledge is too limited
Sorry my bad. There were missing one space.
Try again now.
the first gateway now works,
the second no, I have this error (no gateway_sid)
17-01-31 21:51:23 ERROR (Thread-13) [custom_components.xiaomi] Unknown gateway ip 192.168.1.231
Ok, so the sid is probably wrong for the second gateway.
There should be something like Unknown Xiaomi Gateway SID found at IP
in the log also?
Nope.
I made the search for the word “xiaomi” and the word “gateway”; the only log related is this
7-01-31 21:51:23 ERROR (Thread-13) [custom_components.xiaomi] Unknown gateway ip 192.168.1.231
repeated multiple times
Hmm, strange. But I am quite sure the sid for the second gateway is wrong
and for the first (working) I have this
17-01-31 21:51:15 INFO (MainThread) [homeassistant.bootstrap] Setting up xiaomi
17-01-31 21:51:15 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways
17-01-31 21:51:16 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aaxxxx found at IP 192.168.1.230
1
I put as SID the MAC address in lower case without :
but what should the SID be???
Just modified the code again. So try the latest version again.
I think that sid should be ok
Nope, same as above, on addition for the first gateway in the log is this strange behaviour
17-01-31 22:10:21 INFO (MainThread) [homeassistant.bootstrap] Setting up xiaomi
17-01-31 22:10:21 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways
17-01-31 22:10:21 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:21 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:21 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:21 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:21 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:21 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:26 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429a found at IP 192.168.1.230
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:32 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:37 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:42 INFO (Thread-5) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-01-31 22:10:42 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways
17-01-31 22:10:43 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:43 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:43 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:43 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429aa found at IP 192.168.1.230
17-01-31 22:10:43 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-01-31 22:10:43 INFO (Thread-5) [custom_components.xiaomi] Found 13 devices
17-01-31 22:10:48 INFO (Thread-5) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-01-31 22:10:48 INFO (Thread-5) [custom_components.xiaomi] Creating Multicast Socket
17-01-31 22:10:48 INFO (Thread-5) [custom_components.xiaomi] Listening for broadcast
17-01-31 22:10:48 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=xiaomi>
1
Ok, so the second gateway is not found by HA. Is it on the same network as the other gateway?
different WiFI, but same network
192.168.1.230 one
192.168.1.231 second
the Xiaomi app sees both
Thanks @Danielhiversen.
I’m trying to use it like that but I get:
17-01-31 21:30:07 ERROR (MainThread) [homeassistant.core] Invalid service data for light.turn_on: expected int for dictionary value @ data[‘brightness’]. Got ‘{% set state = states.light.living_room.attributes.brightness + (trigger.event.data.action_value|float)/90 %} {{ state }}’
code:
- alias: Living room Cube rotate trigger: platform: event event_type: cube_action event_data: entity_id: binary_sensor.cube_158d0001035712 action_type: rotate action: service: light.turn_on entity_id: light.living_room data: brightness: > {% set state = states.light.living_room.attributes.brightness + (trigger.event.data.action_value|float)/90 %} {{ state }}
It’'s like it’s just parsing the templates as string and not converting…
Also, do you know how can I debug (trigger.event.data.action_value|float)/90 to know the output value? I need to change it to go from min0-255max.
Thanks.
replace data with template_data, as in my example