How set values for Dummy Switch with mqtt?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
tribal
Normal user
Posts: 10
Joined: 23 Dec 2017, 09:47

How set values for Dummy Switch with mqtt?

#1 Post by tribal » 20 Feb 2018, 15:08

Hi to all!
Can you explaine me how to set values for Dummy Switch with mqtt command?
I have this config on my esp:
Снимок1.JPG
Снимок1.JPG (110.93 KiB) Viewed 10374 times
Снимок.JPG
Снимок.JPG (101.6 KiB) Viewed 10376 times
This command:

Code: Select all

mosquitto_pub -h xxx.xxx.xxx.xxx -t "sonoff_esp/Boot_State/OnBoot_On" -m 1
don't do anything for esp dummy switch (

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How set values for Dummy Switch with mqtt?

#2 Post by grovkillen » 20 Feb 2018, 15:59

You need to use this topic:

Code: Select all

sonoff_esp/cmd
And this payload:

Code: Select all

TaskValueSet,2,1,1
Edit: if TaskValueSet isn't accessible through mqtt then you'll need to create an event.

Please refer to the wiki.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tribal
Normal user
Posts: 10
Joined: 23 Dec 2017, 09:47

Re: How set values for Dummy Switch with mqtt?

#3 Post by tribal » 21 Feb 2018, 18:44

Thanks.
Now all works with http request. With mqtt no lucky.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How set values for Dummy Switch with mqtt?

#4 Post by grovkillen » 21 Feb 2018, 19:07

Now that's not good. What's your setup for MQTT?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tribal
Normal user
Posts: 10
Joined: 23 Dec 2017, 09:47

Re: How set values for Dummy Switch with mqtt?

#5 Post by tribal » 21 Feb 2018, 19:24

MQTT setup in ESP or in MQTT broker server?

PS dummy switches don't save values after reboot.. all switches have "0". That's not what I respect :(
I try to make an external control for boot state of relay after reboot. Maybe I do something wrong? :roll:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How set values for Dummy Switch with mqtt?

#6 Post by grovkillen » 21 Feb 2018, 19:50

Controller setup in esp.

Regarding losing values on reboot, every device does this. We would need to add support for a EEPROM module or other backup memory.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tribal
Normal user
Posts: 10
Joined: 23 Dec 2017, 09:47

Re: How set values for Dummy Switch with mqtt?

#7 Post by tribal » 21 Feb 2018, 20:21

This is my setup:
Снимок.JPG
Снимок.JPG (82.89 KiB) Viewed 10310 times
In advanced settings:
MQTT Retain Msg: on
Message Delay: 1000 [ms]

If all states are lost, how to save values for preferred boot state?
The modules has many free space, why it don't save any values on it? This not logical and uncomfortable.

User avatar
vader
Normal user
Posts: 241
Joined: 21 Mar 2017, 17:35

Re: How set values for Dummy Switch with mqtt?

#8 Post by vader » 21 Feb 2018, 20:27

Due to a limited life time of the flash chips, we reduce all write cycles to a minimum.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How set values for Dummy Switch with mqtt?

#9 Post by grovkillen » 21 Feb 2018, 21:02

Yes that is the reason for not using the main flash for storing values. It's completely logical and how it should work.

Until we have support for external EEPROM (not sure if we will add it), you can use retained messages since the broker will always store these and then they'll be re-imported on boot.

Or you could make a rule that set the trask values on system#boot
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tribal
Normal user
Posts: 10
Joined: 23 Dec 2017, 09:47

Re: How set values for Dummy Switch with mqtt?

#10 Post by tribal » 21 Feb 2018, 21:33

you can use retained messages since the broker will always store these and then they'll be re-imported on boot.
how can I do it?
for now it don't get retained messages. Maybe it depends from espeasy software?
in mosquito I activate retained messages.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How set values for Dummy Switch with mqtt?

#11 Post by grovkillen » 21 Feb 2018, 21:35

Under the advance page. If you study the wiki you will find info like this.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tribal
Normal user
Posts: 10
Joined: 23 Dec 2017, 09:47

Re: How set values for Dummy Switch with mqtt?

#12 Post by tribal » 21 Feb 2018, 21:54

In advanced settings:
MQTT Retain Msg: on
Message Delay: 1000 [ms]
I do it when flash the device. But nothing changed. If it will works for me, I don't ask how to do this! :cry:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How set values for Dummy Switch with mqtt?

#13 Post by grovkillen » 21 Feb 2018, 22:06

So then you need to make sure that the dummy is reporting to the broker. Once every minute or so? Then you need mqtt import to get them back from the broker. But if this is over you knowledge I will make a guide for others to follow, don't have the time right now but soon.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tribal
Normal user
Posts: 10
Joined: 23 Dec 2017, 09:47

Re: How set values for Dummy Switch with mqtt?

#14 Post by tribal » 21 Feb 2018, 22:35

I understand the logic, but I don't understand why it doesn't work in my case!
Maybe it's because I have GIT version: mega-20180104 ?
grovkillen wrote: 21 Feb 2018, 22:06 I will make a guide for others to follow, don't have the time right now but soon.
It will be greate. Don't rush you, It's not urgently.

Upd. the retain for gpio pins now working (in openhab config was disabled retain policy)
But I still can't change the values of dummy switch with mqtt! :twisted:

Post Reply

Who is online

Users browsing this forum: No registered users and 45 guests