Status dashboard switch

I don’t expose all the data from telemetry as it does not make much sense for “home automation control board” type of application, but the message time and RSSI carry useful info for me.
I can’t show any fancy picture right now as I’m at work unfortunately :slight_smile:

Hello Colin

As I said, set a different topic for feedback than the one used command and base the position of the switch on the in message.

As example between node red and a ESP8266 with ESPeasy firmware:

image

image

In this case on node red you publish the command to: /ESP-4/gpio/16 and subscribe the feedback in order to show the state of the switch based on the input to: /ESP-4/luz_pasillo/out

Like this if ESP unit does not respond you will find that switch is not responding neither on dashboard.

Note: I use smartwitch because of the capability to make a toggle which in my opinion is an important missing feature on a switch.

Regards

Hence the confusion as I have been talking about the standard dashboard switch, which does not work the same way.

Colin,

This makes no difference regarding the real state of the switch and the MQTT to subscribe and to publish, I have in between the smartswitch just because of the toggle function, but the same applies to a simple construction with: MQTT IN - DASHBOARD SWITCH - MQTT OUT.

Regards

What stops the switch from changing when you click it if the ESP is offline?

Hello Collin

Check the screen shoot, you should select for indicator “switch icon shows state of the input” that means if you don’t receive feedback you switch will also not change

@davidcgu I am not seeing that option in the config for the dashboard switch node. I am on dashboard 2.7.0, did that feature arrive in a later version?

And how I use it in my dashboard (it's in Estonian :))
image

It's a bathroom where I'm controlling the vent with sonoff-th with TH sensor AM2301 connected to it.
It follows humidity level and turns on automatically if reaches rising edge (70%)
There is also physical switch on the wall with little led indicator on it showing relay status of sonoff-th. This switch is connected to sonoff and turns it on and off no mater of current humidity conditions. But automatic mode stays and if falling or rising edge has been reach, proper mqtt message will be sent out.
Same goes to dashboard button. Dashboard button has colorful states - red for vent in OFF state and green for vent is ON state.
As manual override is allowed, every switch to ON also triggers the countdown timer for an hour. If timer ends, then vent is turned OFF. (as you can have quests in house and regular wall switches are so common to use..) Every OFF command, no mater of source, clears the timer.

At the bottom i display telemetry and sensor data
clock icon - last telemetry message time
wifi icon - RSSI
power icon - relay state
thermometer - temperature value from AM2301
water drop - humidity value from AM2301
gears - just the remainder of high humidity setpoint

colin, you have to uncheck the pass-through option first

On top of that, if you have same topic and don’t uncheck this pass-through option it will create a infinite loop… with one nothing will happen but if you have several it will slow down you dashboard like hell.

Regards

I always have pass through disabled, I just had not noticed the option, and when I just put a node on the flow to look at the options it didn’t appear (as pass through defaults to checked, for some reason that I don’t understand). So I have to agree it can be done, I live and learn, so thanks for that.
How do you cope with remembering the current required state of the output over power cycle?

In my case I have some values that are done by MQTT retain message (I have tested but not used too much as is easy to create undesired loops) but most of my variables are saved on a file and recovered recalling this after restart/deploy based on a tutorial made by Csongor I found on youtube https://www.youtube.com/watch?v=JYQXF9JlOsg&t=99s, for me is working really well, however in my case the change of the variables could be at any time so I had to do as small changes to make it work as I expected.

If you are interested I can share it what changes I have made.

Right now whenever I restart I get back all my important variables, some are internal, some are state of switches, some are values previously selected on a drop down menu, some other text box etc…

Regards

(as pass through defaults to checked, for some reason that I don’t understand).

I think this was the default behavior of the "old" dashboard (contrib-ui) and therefore was kept in order to maintain backwards compatibility. However, I agree that the fact that the pass-through option is checked by default mostly causes unintuitive trouble if not aware of it.

When I added this feature that the switch could show the state of the input, we discussed that this only makes sense if pass-through is disabled, therefore, this option only appears then.

I find this discussion interesting. Would have liked to see it before I made my own design decisions.
Just to show what I did.
I use the switch element in the dashboard to configure the intended state of the switch, which will be sent by node-red to the switch.
And a simple text element to show the actual state as sent by the switch to node-red.
That way I avoided feedback loops. It's not pretty, but understandable for me, and the family.
The picture below shows the switch for the water pump in the garden. Other switches I have implemented in a similar way.

When switch comes from an ESP unit I take anyway the real feedback from ESP topic publish, the benefits are out of discussion in my point of view, regarding how this is supported visually on top of the dashboard switch itself I have a bulb that gets yellow when light is on and a led that moved from green to red, see below difference between on switch on and another off:

image

1 Like

I click the button on the dashboard that publishes a request asking for the status of the switch. If I am subscribed to the topic with the Raspberry Pi client I see the message indicating the status of the switch. I need to see some kind of indication on the dashboard that will tell me the status. I don't know how to do that.

Which bit don't you know how to do? Getting the status from mqtt or displaying it on the dashboard?

I click the button on the dashboard that publishes a request asking for the status of the switch. If I am subscribed to the topic with the Raspberry Pi client snaptube telegram web Ithe status of the switch. I need to see some kind of indication on the dashboard that will tell me the status. I don't know how to do that.
need to see some kind of indication on the dashboard that will tell me the status. I don't know how to do that.

Start by using an MQTT In node subscribed to the topic. Feed that into a debug node to see what you get.