So far Ive worked with boolean types and switches for my automations because i either turn a relay on or off for things like patio lights, home lights etc.
Now I have a roller curtain wired up to an arduino that gets mqtt messages (via a wifi shield). The message tells the curtain to roll up or down (0 or 1):
The thing is I had to code the arduino to only roll up or down for 5 seconds on each command (0 or 1). So at present I dont use the switch but instead I go to developer and just send mqtt messages until the curtain reaches a desired position.
I know the best thing would be to add limit switches and Ill get around to it, but in the meantime I wanted to see if I could find a 3-way switch on HA. 1 position for up, 1 position for down and 1 position for stop.
Ok so here is my configuration.yaml file. The first section MQTT Switches are normal switches. And then the second section MQTT Curtain is my curtain code that I took as sample from here:
I changed the name and command topic. I would need to change the payload_on & _off as well, right? But it would have to be _open, _close & _stop, right?
curtainStatus is the topic to which I post 1’s and 0’s to make it go up or down. So that would be the topic. As for up and down, its controlled via an L298N board where in1HIGH & in2LOW makes it spin in one direction and in1LOW & in2HIGH makes it go down. The stop is both low which i dont have a separate function for, but I could very easily make 2 the mqtt command to call the stop function.
It appears you will have to make changes before you can use MQTT Cover.
It needs two topics, one for publishing commands (commamd_topic) and the other for receiving status (state_topic). If you don’t have a state_topic then you will have to use optimistic mode. In this mode, after a command is sent, it expects no reply from the Arduino and assumes it was received.
Then you must specify the payloads that will be used to command the curtain to go up, down, and stop. If you use a state_topic, you also need to specify the payloads that represent the curtain’s current state.
Set the retain option to false (that’s the default).
groups.yaml
I commented out view and control because I was getting config error of those as invalid options.
garage_doors:
name: Garage Doors
#. view: no
# control: hidden
icon: mdi:garage
entities:
- cover.single //These are named based on my doors, one is double wide the other is single.
customize.yaml
cover.single:
device_class: garage
friendly_name: Garage 1 #change this to whatever you want the door called in your HA UI
configuration.yaml
The switch part shows a switch I use that currently works, but Im replacing it for the cover you told me about.
The cover part is the cover code I added with the options I think I need.
Invalid config for [group]: Entity ID cover.single //These are named based on my doors, one is double wide the other is single. is an invalid entity id for dictionary value @ data['group']['garage_doors']['entities']. Got ['cover.single //These are named based on my doors, one is double wide the other is single.'].
view is an option used by the old States UI and not by the Lovelace UI. It was deprecated several versions ago.
If you want to add a friendly_name or device_class to a cover entity, you can specify it directly in the entity’s configuration rather than in customize.yaml.
So does the cover component provide you with the “3-way switch” you requested?
Please my mark my first post in this thread with the Solution tag. This will automatically place a check-mark next to the topic’s title which signals to other users that this topic has a solution. If others are also looking for a 3-way switch, it will help them find this answer.