I’m trying to use an input_slider together with automation to create a custom MQTT dimmer.
This is the code:
#MQTT DIMMER 1
automation 1:
alias: 'MQTT Input Slider Dimmer1'
trigger:
platform: state
entity_id: input_slider.slider1
action:
service: mqtt.publish
data_template:
topic: kitchen/dimmer1/brightness/set
payload: {{ states.trigger.new_state }}
I have tried several ways for setting payload, but nothing works.
payload: {{ trigger.new_state }}
payload: {{ states.input_slider.slider1 }}
payload: {{ states(trigger.new_state) }}
payload: {{ states(input_slider.slider1) }}
This is the error I get:
> Config directory: /home/pi/.homeassistant/
> Process Process-1:
> Traceback (most recent call last):
> File “/usr/lib/python3.4/multiprocessing/process.py”, line 254, in _bootstrap
> self.run()
> File “/usr/lib/python3.4/multiprocessing/process.py”, line 93, in run
> self._target(*self._args, **self._kwargs)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/main.py”, line 245, in setup_and_run_hass
> skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py”, line 299, in from_config_file
> config_dict = config_util.load_yaml_config_file(config_path)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/config.py”, line 149, in load_yaml_config_file
> conf_dict = load_yaml(config_path)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/util/yaml.py”, line 31, in load_yaml
> return yaml.load(conf_file, Loader=SafeLineLoader) or {}
> File “/usr/local/lib/python3.4/dist-packages/yaml/init.py”, line 72, in load
> return loader.get_single_data()
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 37, in get_single_data
> return self.construct_document(node)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 41, in construct_document
> data = self.construct_object(node)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 86, in construct_object
> data = constructor(self, node)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/util/yaml.py”, line 50, in _ordered_dict
> nodes = loader.construct_pairs(node)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 141, in construct_pairs
> value = self.construct_object(value_node, deep=deep)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 86, in construct_object
> data = constructor(self, node)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/util/yaml.py”, line 50, in _ordered_dict
> nodes = loader.construct_pairs(node)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 141, in construct_pairs
> value = self.construct_object(value_node, deep=deep)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 86, in construct_object
> data = constructor(self, node)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/util/yaml.py”, line 50, in _ordered_dict
> nodes = loader.construct_pairs(node)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 141, in construct_pairs
> value = self.construct_object(value_node, deep=deep)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 86, in construct_object
> data = constructor(self, node)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/util/yaml.py”, line 50, in _ordered_dict
> nodes = loader.construct_pairs(node)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 141, in construct_pairs
> value = self.construct_object(value_node, deep=deep)
> File “/usr/local/lib/python3.4/dist-packages/yaml/constructor.py”, line 86, in construct_object
> data = constructor(self, node)
> File “/usr/local/lib/python3.4/dist-packages/homeassistant/util/yaml.py”, line 58, in _ordered_dict
> if key in seen:
> TypeError: unhashable type: ‘OrderedDict’
Anyone know what to do?
(The reason I dont use the built-in MQTT-dimmer in HA, is that whenever the brightness-value is set - HA is also setting payload to “on”, which in my setup is the same as brightness=255.)
Grateful for any help!!