soesas
(Sascha Schöne)
May 4, 2022, 7:38pm
1
I tried to put the mqtt in a separate .yaml file. so the config.yaml does not get too full.
So in my config.yaml I put:
mqtt: !include mqtt.yaml
I crated a file called
mqtt.yaml
- plattform: mqtt
unique_id: Rasenbewässerung Hochbeet Nord
name: "Rasenbewässerung Hochbeet Nord"
state_topic: mqtt/irrigation/relay1/state
command_topic: mqtt/irrigation/relay1/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
- platform: mqtt
unique_id: Tropfbewässerung Terrasse
state_topic: mqtt/irrigation/relay2/state
command_topic: mqtt/irrigation/relay2/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
name: "Tropfbewässerung Terrasse"
- platform: mqtt
unique_id: Tropfbewässerung Haus
state_topic: mqtt/irrigation/relay3/state
command_topic: mqtt/irrigation/relay3/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
name: "Tropfbewässerung Haus"
- platform: mqtt
unique_id: Tropfbewässerung Hochbeet
state_topic: mqtt/irrigation/relay4/state
command_topic: mqtt/irrigation/relay4/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
name: "Tropfbewässerung Hochbeet"
- platform: mqtt
unique_id: Rasenbewässerung Terrasse
state_topic: mqtt/irrigation/relay5/state
command_topic: mqtt/irrigation/relay5/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
name: "Rasenbewässerung Terrasse"
- platform: mqtt
unique_id: Dummy Switch 6
state_topic: mqtt/irrigation/relay6/state
command_topic: mqtt/irrigation/relay6/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
name: "Test Schalter 6"
- platform: mqtt
unique_id: Rasenbewässerung rechts
state_topic: mqtt/irrigation/relay7/state
command_topic: mqtt/irrigation/relay7/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
name: "Rasenbewässerung rechts"
- platform: mqtt
unique_id: Schalter 8
state_topic: mqtt/irrigation/relay8/state
upon checking the config it gives me the following error:
Invalid config for [mqtt]: expected dictionary for dictionary value @ data['mqtt']. Got [OrderedDict([('plattform', 'mqtt'), ('unique_id', 'Rasenbewässerung Hochbeet Nord'), ('name', 'Rasenbewässerung Hochbeet Nord'), ('state_topic', 'mqtt/irrigation/relay1/state'), ('command_topic', 'mqtt/irrigation/relay1/switch'), ('payload_on', '1'), ('payload_off', '0'), ('state_on', 'ON'), ('state_off', 'OFF')]), OrderedDict([('platform', 'mqtt'), ('unique_id', 'Tropfbewässerung Terrasse'), ('state_topic', 'mqtt/irrigation/relay2/state'), ('command_topic', 'mqtt/irrigation/relay2/switch'),.... (See /config/configuration.yaml, line 12).
What do I do??
Thanks for the answer.
tom_l
May 5, 2022, 12:38am
2
You don’t put binary sensors using the mqtt platform under the mqtt:
integration, they go under the binary_sensor:
integration, likewise for sensors using the mqtt platform, they go under sensors:
. Look at the examples:
soesas
(Sascha Schöne)
May 5, 2022, 12:36pm
3
Thanks.
The post you referring to explains about sensors. From what I understand and I’m more likely to refer to buttons.
MQTT Buttons
So that way I could exclude the in mqtt from config.yaml
button: !include mqtt.yaml?
Confused…
tom_l
May 5, 2022, 12:46pm
4
button: !include buttons.yaml
buttons.yaml:
- plattform: mqtt
unique_id: Rasenbewässerung Hochbeet Nord
name: "Rasenbewässerung Hochbeet Nord"
state_topic: mqtt/irrigation/relay1/state
command_topic: mqtt/irrigation/relay1/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
- platform: mqtt
unique_id: Tropfbewässerung Terrasse
etc...
soesas
(Sascha Schöne)
May 6, 2022, 3:27pm
5
I did as suggested.
added in confog.yaml
button: !include buttons.yaml
created a new file called buttons.yaml
unique_id: Rasenbewässerung Hochbeet Nord
name: "Rasenbewässerung Hochbeet Nord"
state_topic: mqtt/irrigation/relay1/state
command_topic: mqtt/irrigation/relay1/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
I get this as an error in chkconfig.
Invalid config for [button]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 12).
soesas
(Sascha Schöne)
May 6, 2022, 8:27pm
8
I changed buttons.yaml to:
- platform: mqtt
unique_id: Rasenbewässerung Hochbeet Nord
name: "Rasenbewässerung Hochbeet Nord"
state_topic: mqtt/irrigation/relay1/state
command_topic: mqtt/irrigation/relay1/switch
payload_on: "1"
payload_off: "0"
state_on: "ON"
state_off: "OFF"
I get
Invalid config for [button.mqtt]: [state_topic] is an invalid option for [button.mqtt]. Check: button.mqtt->state_topic. (See ?, line ?).
in result. So i changed it back for now.
tom_l
May 7, 2022, 12:32am
9
You have used invalid options. See the available ones in the docs:
soesas
(Sascha Schöne)
May 7, 2022, 5:20am
10
I get it.
So by using the button configuration I cannot use the state topic.
Right now I am using the binary sensor where it is also possible to get state information displayed.
I guess I’d rather leave it in the config.yaml and do not exclude it into a separate file.
tom_l
May 7, 2022, 5:30am
11
It has nothing to do with your includes. It’s that fact that buttons and binary_sensors have different configuration options.
soesas
(Sascha Schöne)
May 7, 2022, 8:57am
12
So why can’t include them as a switch?
That is what I originally tried.
That way I can keep the state topic in my mqtt file. I would like to know so whether the mqtt switch actually changed to on or not. I do not seem to be able to do that by using buttons.
Would
Binary_sensors: !include buttons.yaml
Work?
tom_l
May 7, 2022, 9:04am
13
You can’t make up integration options. You can only use the ones specified. So if it is an mqtt switch, use the mqtt switch options.
And you don’t use capital letters for the integration key.
So you could put valid button platform configs here:
buttons: !include buttons.yaml
Switch platforms here:
buttons: !include switches.yaml
Binary sensors here:
binary_sensors: !include switches.yaml
etc…
No you tried to include a binary sensor under the mqtt:
integration using an include. Which I already explained. !include mqtt.yaml not working - #2 by tom_l