Shelly 1 get status

hello,
I would like to use shelly1 but have not yet found the right communication for me.

Since I only have switches installed at home, I would like to query the switch with shelly1 and send the status to node-red and then use it to switch on the hue-phillips lamps.
I go this way to not have to disconnect the lamps from the power supply.

I have connected the switch to pw input. It also works, the relay clicks. I use node-red-contrib-shelly from @windkh to control shelly from node-red, but this node can not output the status of sw.

so i use http-request and query the ip address for status. I have to do this with timestamp repeat every 1 sec.

I don't like this solution so much.
Would this be a better solution with mqtt? At the moment I can't get mqqt connection established. I am using aede's mqtt broker and it also says connected and all my mqtt nodes are connected but the shelly is not connected when i query the status.

thanks for the help

You can get the status of the switch by just sending an empty message into the node e.g. using a timer or inject node.

1 Like

MQTT seems to be the best option IMO.

Have you enabled MQTT and entered your server details in the Shelly setup? - Welcome to Shelly Technical Documentation | Shelly Technical Documentation
NOTE - enabling MQTT in the Shelly will disable the Shelly Cloud service.

If the Shelly is connected to your Aedes broker, just post an 'update' request to get the status - like this;

[{"id":"e37c1996.57d048","type":"mqtt in","z":"8e37609b.e7282","name":"Shelly","topic":"shellies/#","qos":"2","datatype":"auto","broker":"aa11e6d8.6cd088","x":120,"y":510,"wires":[["56a32b47.4eaa34"]]},{"id":"56a32b47.4eaa34","type":"debug","z":"8e37609b.e7282","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":360,"y":510,"wires":[]},{"id":"281208fe.235518","type":"inject","z":"8e37609b.e7282","name":"Report status","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"shellies/command","payload":"update","payloadType":"str","x":145,"y":570,"wires":[["93d7fdcf.70227"]]},{"id":"93d7fdcf.70227","type":"mqtt out","z":"8e37609b.e7282","name":"","topic":"","qos":"0","retain":"false","broker":"aa11e6d8.6cd088","x":335,"y":570,"wires":[]},{"id":"aa11e6d8.6cd088","type":"mqtt-broker","name":"Local server","broker":"192.168.1.8","port":"1883","clientid":"Local node-RED","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"admin","birthQos":"0","birthRetain":"false","birthPayload":"Hello from Local node-RED","closeTopic":"admin","closeQos":"0","closeRetain":"false","closePayload":"Local node-RED is about to exit","willTopic":"admin","willQos":"0","willRetain":"false","willPayload":"Local node-RED has now exited"}]
1 Like

I'm so dumb. I've red it several times, but somehow didnt notice that as solution...thank you very much for quick response

I've found your 1&1 flow for shelly, and was trying to set it up for me working with your examples. the http request works without any problem, but mqqt doesnt.
I've imported your flow, and my nodes show me "connected", when I deploy "report status", this is what I get back:
image

Have you updated the Shelly firmware and turned on the MQTT setting? I got my Shelly's in last winter's black friday sale and the firmware they came with needed updating.

Yes, my firmware is up to date.
I did turn the mqtt settings on. What I don't understand is wich ip i have to use. I've tried with localhost:1883.
Currently I run node red in Windows VM threw hypervi. Today I will set up my new RPi and try it again.
May this be the issue?

Assuming you have not changed the default MQTT port, is should be 1883.

Is this eventually going to be controlled by the Pi?
If so, let's get the Pi up and running first, and then we'll get the Shelly connected.

In the Shelley you have to give it the ip address of the device running the mqtt broker, which is presumably the pi.

1 Like

got it now,
after I've set up node red on pi today, I've used the pi ip for mqtt broker wth 1883 port and it just works.

What is actually my advantage to use mqtt instead of http request with interval?
and 2nd question, do I have to secure my mqtt connections with user and password in local net?

MQTT vs. HTTP: which one is the best for IoT? | by Marina Serozhenko | MQTT Buddy | Medium.

No, you dont "have to". If the MQTT traffic was over the internet then it would be strongly recommended.
Also, if your wifi is wide open then someone in the vicinity could connect and operate your IoT stuff (but TBH, if your wifi was wide open, there is far worse things that could happen). The answer is "up to you"

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.