ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
gatsu_1981
Normal user
Posts: 12
Joined: 15 Jan 2018, 02:08

ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#1 Post by gatsu_1981 » 15 Jan 2018, 02:18

Hello,

I'm using ESPEasy on a couple of devices.
One of them is a fake Wemos D1 Mini (1MB), the other one is a real Wemos D1 Mini (4MB).
Both seems configured well, connected on mosquitto server on my Lede (OpenWRT) router.
My first try was with the embedded Home Assistant MQTT server, but I read online that it's not pretty good, so I switched everything to Mosquitto.

I can see everything connected and logged via MQTT.fx, but both Wemos doesn't accept commands via MQTT.

I try to publish on them

Code: Select all

/ESP_Easy/cmd/neopixel/1,255,0,0
or

Code: Select all

/ESP_Easy_2/Rele/Switch,1
But it's not switching (for esp n.2) and turning on/off/changing color of the led (esp n.1).

What I did wrong?
I can see in the log that the unit "get" the MQTT message, but it seems that it's just not "understanding" it correctly:

Code: Select all

1814362 : MQTT : Topic: /ESP_Easy/cmd/neopixel/1,255,0,0
1814362 : MQTT : Payload: 
After this command, even if the led was previously switched on from a web command, the led turns off.
Instead,

Code: Select all

/ESP_Easy/cmd/NeoPixelAll/255,255,255
turns my led red, even if it was previously totally set to white (255,255,255).

Using in the "Command" box the text "neopixel,1,255,0,0" and hitting submit, or using via HTTP ?cmd=neopixel,1,255,0,0, both colour my picture red.
And using the switch command the same way, I can hear the relay clicking.

Please help me, I'm stuck :(

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

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#2 Post by grovkillen » 15 Jan 2018, 10:34

Yes I can confirm this (running mega-20180104).

Bug reported here: https://github.com/letscontrolit/ESPEasy/issues/728

EDIT: I see that you use this way of publishing...

Code: Select all

/ESP_Easy/cmd/neopixel/1,255,0,0
Correct is:

Code: Select all

TOPIC: /ESP_Easy/cmd
PAYLOAD: neopixel,1,255,0,0
But I see no response what so ever even using the correct way of posting commands.

EDIT2: OOOOOPS... I forgot that the topic is case sensitive. :oops:
But discover a bug none the less... :P
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:

gatsu_1981
Normal user
Posts: 12
Joined: 15 Jan 2018, 02:08

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#3 Post by gatsu_1981 » 15 Jan 2018, 12:47

Hi,

I was using the /cmd/neopixel/payload style because I noticied that "it got" something.
I tried with the /cmd/neopixel,1,255,255,255 style but it did not work at all.

I can confirm that:

Code: Select all

/ESP_Easy/cmd/neopixel,1,255,255,255
/ESP_Easy/cmd/Neopixel,1,255,255,255
/ESP_Easy/cmd/NeoPixel,1,255,255,255
does not have any effect. If led was green before, lad stay green after any command.

But, as stated before,

Code: Select all

/ESP_Easy/cmd/NeoPixel/1,255,255,255
Turns all led off :(

I think that the path (or the commands) are not case sensitive, in the arduino code for the neopixel plugin the functions are wrote that way but I think it's accepting in lowercase.

The strange thing is that it's not recognizing topic from payload, it always show empty payload to me, even if I use curly brackets (like I have to declare bigger payloads in Home Assistant).

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

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#4 Post by grovkillen » 15 Jan 2018, 13:12

gatsu_1981 wrote: 15 Jan 2018, 12:47 Hi,

I was using the /cmd/neopixel/payload style because I noticied that "it got" something.
I tried with the /cmd/neopixel,1,255,255,255 style but it did not work at all.

I can confirm that:

Code: Select all

/ESP_Easy/cmd/neopixel,1,255,255,255
/ESP_Easy/cmd/Neopixel,1,255,255,255
/ESP_Easy/cmd/NeoPixel,1,255,255,255
does not have any effect. If led was green before, lad stay green after any command.

But, as stated before,

Code: Select all

/ESP_Easy/cmd/NeoPixel/1,255,255,255
Turns all led off :(

I think that the path (or the commands) are not case sensitive, in the arduino code for the neopixel plugin the functions are wrote that way but I think it's accepting in lowercase.

The strange thing is that it's not recognizing topic from payload, it always show empty payload to me, even if I use curly brackets (like I have to declare bigger payloads in Home Assistant).
But you are not sending any payload? Only topic as far as I can see.
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:

gatsu_1981
Normal user
Posts: 12
Joined: 15 Jan 2018, 02:08

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#5 Post by gatsu_1981 » 15 Jan 2018, 13:36

How do I send /specify the payload?
Can you make a full example for me please?

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

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#6 Post by vader » 15 Jan 2018, 14:13

That stands all in the Wiki. Help for Mosquitto: mosquitto_pub --help

Send a Value: mosquitto_pub -h hostname -t topic -m payload

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#7 Post by papperone » 15 Jan 2018, 14:34

I can confirm MQTT works so next step to troubleshoot you shoudl tell us how do you send MQTT command as they are obviously wrong...
You need to have:
TOPIC: "/ESP_Easy/cmd"
PayLoad: "neopixel,1,255,0,0"
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

gatsu_1981
Normal user
Posts: 12
Joined: 15 Jan 2018, 02:08

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#8 Post by gatsu_1981 » 15 Jan 2018, 14:47

Hello,

Sorry, my fault.
I was specifyng the payload on the same line on the MQTT tool.
I can see that the big white box below is not for logs, is for payload :D

Now it's catching the payload, but I'm not home now so I can't see if the led is lit :D

Code: Select all

Log
46773427 : MQTT : Topic: /ESP_Easy/cmd/
46773427 : MQTT : Payload: NeoPixel,1,255,255,255

gatsu_1981
Normal user
Posts: 12
Joined: 15 Jan 2018, 02:08

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#9 Post by gatsu_1981 » 15 Jan 2018, 19:29

OK,

It's working with:

Code: Select all

topic: /ESP_Easy/cmd
payload: NeoPixel,1,255,255,255
payload looks like case unsensitive, so it's working even with lowercase "neopixel".

Now, next step.
Can I command it via device name? like using:

Code: Select all

/ESP_Easy/single
and just "1,255,0,0" for setting it to red?

It would be easier to create a template for Home Assistant this way.

gatsu_1981
Normal user
Posts: 12
Joined: 15 Jan 2018, 02:08

Home assistant configuration with ESPEasy Neopixel

#10 Post by gatsu_1981 » 15 Jan 2018, 20:44

Ok, my turn to contribute now.
This is a working mqtt_template light setting for home assistant, with my configuration.

Code: Select all

light:
  - platform: mqtt_template
    name: "RGB Led"
    command_topic: "/ESP_Easy/cmd"
    command_off_template: 'Neopixel,1,0,0,0'
    command_on_template: 'Neopixel,1,{{ red|d }},{{ green|d }},{{ blue|d }}'
    red_template: "{{ value.split(',')[2].split(',')[0] }}"
    green_template: "{{ value.split(',')[2].split(',')[1] }}"
    blue_template: "{{ value.split(',')[2].split(',')[2] }}"

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

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#11 Post by tribal » 23 Jan 2018, 18:42

Hi. I see you understand how to set up communication espeasy and HASS. I'm confused. I don't understand how to connect my espeasy device and th HASS across mosquito! The mosquito can receive and send commands to relay and it controlled by commands through mosquito_pub command. Maybe I do something wrong? :roll:
I can send command to switch relay on, but in few seconds the "switch" in HASS back to off state (the command to off the relay don't send :evil: )

Can you post you configuration for espeasy (controller side) and configuration for HASS in mqtt section?

MQtt config in HASS:

Code: Select all

mqtt:
  broker: 192.168.1.40
  port: 1883
switch config:

Code: Select all

switch 1:
  platform: mqtt
  name: "Sonoff1"
  state_topic: "sonoff_esp/GPIO/0"
  command_topic: "sonoff_esp/GPIO/12"
  payload_on: "1"
  payload_off: "0"
  qos: 1
  retain: true
customize config for switch1:

Code: Select all

switch.sonoff1:
      friendly_name: Sonoff 01 (flowers)
      icon: mdi:lightbulb-outline  
      assumed_state: false

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

Re: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#12 Post by grovkillen » 23 Jan 2018, 20:32

tribal wrote: 23 Jan 2018, 18:42 Hi. I see you understand how to set up communication espeasy and HASS. I'm confused. I don't understand how to connect my espeasy device and th HASS across mosquito! The mosquito can receive and send commands to relay and it controlled by commands through mosquito_pub command. Maybe I do something wrong? :roll:
I can send command to switch relay on, but in few seconds the "switch" in HASS back to off state (the command to off the relay don't send :evil: )

Can you post you configuration for espeasy (controller side) and configuration for HASS in mqtt section?

MQtt config in HASS:

Code: Select all

mqtt:
  broker: 192.168.1.40
  port: 1883
switch config:

Code: Select all

switch 1:
  platform: mqtt
  name: "Sonoff1"
  state_topic: "sonoff_esp/GPIO/0"
  command_topic: "sonoff_esp/GPIO/12"
  payload_on: "1"
  payload_off: "0"
  qos: 1
  retain: true
customize config for switch1:

Code: Select all

switch.sonoff1:
      friendly_name: Sonoff 01 (flowers)
      icon: mdi:lightbulb-outline  
      assumed_state: false
Try this.

Code: Select all

switch 1:
  platform: mqtt
  name: "Sonoff1"
  state_topic: "sonoff_esp/status"
  command_topic: "sonoff_esp/cmd"
  payload_on: "gpio,12,1"
  payload_off: "gpio,12,0"
  qos: 1
  retain: true
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: ESPEasy mega-20180114 (normal,dev,testing) not accepting command via MQTT

#13 Post by tribal » 24 Jan 2018, 11:56

grovkillen wrote: 23 Jan 2018, 20:32 Try this.

Code: Select all

switch 1:
  platform: mqtt
  name: "Sonoff1"
  state_topic: "sonoff_esp/status"
  command_topic: "sonoff_esp/cmd"
  payload_on: "gpio,12,1"
  payload_off: "gpio,12,0"
  qos: 1
  retain: true
Nope :(
The switch is going ON from OFF when I clic on it (relay is ON too), but in few seconds return to "OFF" state without the phisical switching the relay.
As i understand, for some reasons, the switch in HASS cant recieve the state from my relay. :?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 41 guests