Hi,
Working on an domoticz/home assistant integration using mqtt and ha automations, I’m looking for some slugify filter in template. For example this automation will listen at domoticz/out mqtt messages and publish a config message:
- alias: DZ dev switches
trigger:
- platform: mqtt
topic: 'domoticz/out'
condition:
condition: template
value_template: '{{ trigger.payload_json.dtype == "Light/Switch" }}'
action:
- condition: template
value_template: '{{ states("switch.domoticz_"+trigger.payload_json.idx|string) == "unknown" }}'
- service: mqtt.publish
data_template:
topic: 'homeassistant/switch/domoticz_{{ trigger.payload_json.idx }}/config'
payload_template: '{"name":"domoticz_{{ trigger.payload_json.idx|string }}","command_topic":"homeassistant/switch/domoticz_{{ trigger.payload_json.idx|string }}/power","state_topic":"homeassistant/switch/domoticz_{{ trigger.payload_json.idx|string }}/state","payload_off":"Off","payload_on":"On"}'
This work, the switch name is based on domoticz id but I want to build a switch name based on domoticz name which is something free. A slugify filter will help to make a valid name removing special chars, changing spaces … to make a good component name.