I can create automatons, scenes, scripts through CURL but trying to figure out how to create / modify helpers like input_select seems to have me stumped.
I’ve tried exploring /api/config/input_select/config with no success
I can create automatons, scenes, scripts through CURL but trying to figure out how to create / modify helpers like input_select seems to have me stumped.
I’ve tried exploring /api/config/input_select/config with no success
Currious to know how you even do that, tbh…
Just some of my code (bash) to build and post the json for a scene or automation.
One of my use cases is that ZigBee scenes don’t always take effect, so I apply the scene 3 times with a delay between
lower() { tr '[A-Z]' '[a-z]'; }
ha_post() {
curl --silent $1 \
-X POST \
-H "authorization: Bearer $(ha_token)" \
-H "Content-Type: application/json" \
--data-binary @-
}
automation_url="http://192.168.1.x:8123/api/config/automation/config"
scene_url="http://192.168.1.x:8123/api/config/scene/config"
item=${room_id}${phase_id}
scene_name=$(echo ${room_name}_${phase_name} | lower)
echo Making Scene ${item} - ${scene_name}
echo '{}' \
| jq ".name=\"${room_name} - ${phase_name}\"" \
| jq ".icon=\"mdi:weather-sunny\"" \
| jq ".entities={}" \
| ha_post ${scene_url}/${item}
echo Making Automation ${item} - ${room_name} - ${phase_name}
echo '{}' \
| jq ".id=\"${item}\"" \
| jq ".alias=\"${room_name} - ${phase_name}\"" \
| jq ".description=\"${room_name} - ${phase_name}\"" \
| jq ".mode=\"single\"" \
| jq ".trigger=[]" \
| jq ".condition=[]" \
| jq ".action[0].service=\"input_select.select_option\"" \
| jq ".action[0].data.option=\"${phase_name}\"" \
| jq ".action[0].target.entity_id=\"input_select.phase_${room_lower}\"" \
| jq ".action[1].repeat.count=3" \
| jq ".action[1].repeat.sequence[0].scene=\"scene.${scene_name}\"" \
| jq ".action[1].repeat.sequence[1].delay.milliseconds=200" \
| ha_post ${automation_url}/${item}
Cool. Strange that it is undocumented…
I used the browser network debug to capture the traffic. I’ve not been successful with the input_* elements because they seem to be WebSocket and I haven’t spent the additional energy to figure them out