@gjbadros wrote:
Not sure if it’s general enough to be of use to others, but I built a little grammar-based language for specifying parts of my YAML configuration. The below github repository contains my tool – hass-hgl-to-yaml.py – which converts from a file containing “Hass Grammar Language” (HGL) into the YAML that homeassistant understands natively. This allows me to write various concise automation rules in a more concise and natural way. E.g.,
when {pantry,kitchen}_ir is Normal for 3 minutes do turn_off(light.mh_m_*)
It also makes for easier mapping of MQTT messages to actions:
when EH_media_{pause,play,play_pause,volume_up,volume_down,channel_down} do media_player.media_*(entry_hall)
and paired behaviors keyed off of the time of day:
sunrise ... solar_noon -01:00:00 with cover.mh_m_great_room_upper_east start when sunny: cover.close_cover end: cover.open_cover
The script is here: https://github.com/gjbadros/hass-hgl-to-yaml
YMMV: I’m not trying to replace YAML and believe that YAML is a great choice for what Home Assistant is trying to do – I’m just trying to capture some highly repetitive patterns on my YAML because of the volume of devices I have and the automations needed to support them.
Posts: 1
Participants: 1