Created
June 4, 2018 07:10
-
-
Save wwj718/ebbf89e696e8d8b80374969490755a67 to your computer and use it in GitHub Desktop.
使用python来定制hass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.home-assistant.io/components/python_script/ | |
entity_id = data.get('entity_id') | |
rgb_color = data.get('rgb_color', [255, 255, 255]) | |
if entity_id is not None: | |
service_data = {'entity_id': entity_id, 'rgb_color': rgb_color, 'brightness': 255 } | |
hass.services.call('light', 'turn_on', service_data, False) | |
else: | |
service_data = {'rgb_color': rgb_color, 'brightness': 255 } | |
hass.services.call('light', 'turn_on',service_data,False) |
不存在缓存,可以即时修改,无需重启(只是在configuration.yaml
添加python_script:
需要重启一下)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
~/.homeassistant/python_scripts/light_main_on.py