I’ve been figuring out the integration of a 3rd party automation controller and its entities and now have 2-way communication and control (ie I can use HASS or native interfaces that the state of the entity is kept aligned).
Next step is to roll this out for 10s of entities eg lights, areas etc. The 3rd party controller allows spaces in the names, HASS doesn’t in its entity names. I could add pages of similar entries for each light etc but is there a way to programatically convert a name with spaces to a name with eg underscores?
eg the following webhooks work for one light, if I could get the light name that the 3rd party system uses into an entity name I could have 1 webhook for each class of entity.
Thanks
- alias: cortex light state
description: "update light status on webhook message"
trigger:
- platform: webhook
webhook_id: cortex-light-state
action:
service: python_script.hass_entities
data:
action: set_state
entity_id: light.familyrm_light_star
state: "{% if 'On' in trigger.json.Cortex_HAAPI.State %}on {% else %}off {% endif -%}"
#
Similarly for control I’ve hard coded but if the entity name could be converted to one with spaces it would simplify things
#rest_command:
familyrm_light_star_off:
url: http://192.168.0.78/api/v1/json/objects/family%20room%20star?Turn%20off=1
method: POST
headers:
authorization: !secret CortexAuthBasic
content_type: "application/json"
payload: "{}"