Skip to content

Instantly share code, notes, and snippets.

@wwj718
Created June 4, 2018 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwj718/ebbf89e696e8d8b80374969490755a67 to your computer and use it in GitHub Desktop.
Save wwj718/ebbf89e696e8d8b80374969490755a67 to your computer and use it in GitHub Desktop.
使用python来定制hass
# 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)
@wwj718
Copy link
Author

wwj718 commented Jun 4, 2018

~/.homeassistant/python_scripts/light_main_on.py

@wwj718
Copy link
Author

wwj718 commented Jun 4, 2018

不存在缓存,可以即时修改,无需重启(只是在configuration.yaml添加python_script:需要重启一下)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment