Template filters, need some "slugify" filter

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.

Is there any progress on this? The above automation isn’t working because of a bad indentation which I can’t discover to fix. Really like to integrate my Domoticz switches in HA. This could be a simple solution

Hi steef84,

Perhaps you can read my last post in this thread: https://community.home-assistant.io/t/help-with-mqtt-templating-from-domoticz/8375/35

The HA name declared is based on the domoticz one and finally HA will “slugify” this name, this final name can be used in automations, so it’s “name” based.

For example if you have a switch “My Switch” it’s displayed “My Switch (dz)” in HA (I’ve add (dz) but this can be changed) and the final switch name will be switch.my_switch_dz