Hi all,
Long time follower, first time writer.
To cut to the chase, I have hit a road block.
I am able to publish a (OpenHAB MQTT) state change for a GPIO pin (e.g.13) and the ESPEasy will react with the state change and send back the state. The logs also confirm that there is a SW: change and (if you have a task associated) an EVENT: will be stated.
i.e.
mosquitto_pub -h 127.0.0.1 -u mqtt_user -P <password> -t MPRSx8/gpio/13 -m "0"
mosquitto_pub -h 127.0.0.1 -u mqtt_user -P <password> -t MPRSx8/gpio/13 -m "1"
mosquitto_sub -h 127.0.0.1 -u mqtt_user -P <password> -v -t "MPRSx8/#"
MPRSx8/GPIO-13/Switch 0
MPRSx8/GPIO-13/Switch 1
these will change the state of gpio13, naturally.
however if I issue the same command to change the state of a pcfgpio (a virtual port off of the PCF8574), nothing happens....
well the OpenHAB MQTT seems to respond by publishing the change of state, however it seems as if the task in ESPEasy does not even get notified of the request.
i.e.
mosquitto_pub -h 127.0.0.1 -u mqtt_user -P <password> -t MPRSx8/Relay_1/Switch -m "0"
mosquitto_pub -h 127.0.0.1 -u mqtt_user -P <password> -t MPRSx8/Relay_1/Switch -m "1"
mosquitto_sub -h 127.0.0.1 -u mqtt_user -P <password> -v -t "MPRSx8/#"
MPRSx8/status/LWT Connected
MPRSx8/Relay_1/Switch 0
MPRSx8/Relay_2/Switch 1
*** but the relay doesn't toggle***
The only way I was able to issue the request with the cmd but that then creates a whole new set of problems with integration into Home Assitant, etc...
i.e.
mosquitto_pub -h 127.0.0.1 -u mqtt_user -P <password> -t MPRSx8/cmd -m "pcfgpio,69,0"
mosquitto_pub -h 127.0.0.1 -u mqtt_user -P <password> -t MPRSx8/cmd -m "pcfgpio,69,1"
*****
MPRSx8/cmd pcfgpio,69,1
MPRSx8/status {
"log": "GPIO OUTPUT 69 Set to 1",
"plugin": 19,
"pin": 69,
"mode": "output",
"state": 1
}
MPRSx8/Relay_1/Switch 0 (Inverse logic ticked)
*****
MPRSx8/cmd pcfgpio,69,0
MPRSx8/status {
"log": "GPIO OUTPUT 69 Set to 0",
"plugin": 19,
"pin": 69,
"mode": "output",
"state": 0
}
MPRSx8/Relay_1/Switch 1 (Inverse logic ticked)
******
So it seems that either MQTT cannot send to virtual GPIO's (pcfgpio) ports on ESPEasy or the syntax is not correct?
The below is the task list I have & my OpenHAB MQTT setup:
(Solved) MQTT (OpenHAB, HA and any standard) cannot control Virtual GPIO's (PCF8574)?
Moderators: grovkillen, Stuntteam, TD-er
(Solved) MQTT (OpenHAB, HA and any standard) cannot control Virtual GPIO's (PCF8574)?
- Attachments
-
- Screen Shot 2019-02-18 at 3.20.25 pm.png (72.34 KiB) Viewed 5087 times
Last edited by Mravko on 21 Feb 2019, 00:14, edited 1 time in total.
Re: (Solved) OpenHAB MQTT cannot control Virtual GPIO's (PCF8574)?
Well, partially solved...
I have a workaround that works well (almost a proper solution).
Looking into the Switch input - PCF8574 .ino file I realised that it wasn't listening for the right message coming from MQTT, so I experimented with it and found the right syntax.
this is the configuration (in configuration.yaml)
switch:
platform: mqtt
name: "MPRSx8 Switch 1"
state_topic: "MPRSx8/Relay_1/Switch"
command_topic: "MPRSx8/pcfgpio/69"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 1:
platform: mqtt
name: "MPRSx8 Switch 2"
state_topic: "MPRSx8/Relay_2/Switch"
command_topic: "MPRSx8/pcfgpio/70"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 2:
platform: mqtt
name: "MPRSx8 Switch 3"
state_topic: "MPRSx8/Relay_3/Switch"
command_topic: "MPRSx8/pcfgpio/71"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 3:
platform: mqtt
name: "MPRSx8 Switch 4"
state_topic: "MPRSx8/Relay_4/Switch"
command_topic: "MPRSx8/pcfgpio/72"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 4:
platform: mqtt
name: "MPRSx8 Switch 5"
state_topic: "MPRSx8/Relay_5/Switch"
command_topic: "MPRSx8/pcfgpio/65"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 5:
platform: mqtt
name: "MPRSx8 Switch 6"
state_topic: "MPRSx8/Relay_6/Switch"
command_topic: "MPRSx8/pcfgpio/66"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 6:
platform: mqtt
name: "MPRSx8 Switch 7"
state_topic: "MPRSx8/Relay_7/Switch"
command_topic: "MPRSx8/pcfgpio/67"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 7:
platform: mqtt
name: "MPRSx8 Switch 8"
state_topic: "MPRSx8/Relay_8/Switch"
command_topic: "MPRSx8/pcfgpio/68"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
and now everything works perfect!
Mravko out!
I have a workaround that works well (almost a proper solution).
Looking into the Switch input - PCF8574 .ino file I realised that it wasn't listening for the right message coming from MQTT, so I experimented with it and found the right syntax.
this is the configuration (in configuration.yaml)
switch:
platform: mqtt
name: "MPRSx8 Switch 1"
state_topic: "MPRSx8/Relay_1/Switch"
command_topic: "MPRSx8/pcfgpio/69"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 1:
platform: mqtt
name: "MPRSx8 Switch 2"
state_topic: "MPRSx8/Relay_2/Switch"
command_topic: "MPRSx8/pcfgpio/70"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 2:
platform: mqtt
name: "MPRSx8 Switch 3"
state_topic: "MPRSx8/Relay_3/Switch"
command_topic: "MPRSx8/pcfgpio/71"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 3:
platform: mqtt
name: "MPRSx8 Switch 4"
state_topic: "MPRSx8/Relay_4/Switch"
command_topic: "MPRSx8/pcfgpio/72"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 4:
platform: mqtt
name: "MPRSx8 Switch 5"
state_topic: "MPRSx8/Relay_5/Switch"
command_topic: "MPRSx8/pcfgpio/65"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 5:
platform: mqtt
name: "MPRSx8 Switch 6"
state_topic: "MPRSx8/Relay_6/Switch"
command_topic: "MPRSx8/pcfgpio/66"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 6:
platform: mqtt
name: "MPRSx8 Switch 7"
state_topic: "MPRSx8/Relay_7/Switch"
command_topic: "MPRSx8/pcfgpio/67"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
switch 7:
platform: mqtt
name: "MPRSx8 Switch 8"
state_topic: "MPRSx8/Relay_8/Switch"
command_topic: "MPRSx8/pcfgpio/68"
payload_on: "0"
payload_off: "1"
# optimistic: true
qos: 0
retain: true
and now everything works perfect!
Mravko out!
Re: (Solved) OpenHAB MQTT cannot control Virtual GPIO's (PCF8574)?
I have a suggestion:
I believe this is simple to be solved for good...
I'm not so good at programing at all but I conceptually know what needs to be done.
In "_P019_PCF8574.ino" you need to add a function that will take a command from the "%sysname%/%tskname%/%valname%"
and the payload is then either a "1" or "0".
Then the PCF8574 plugin will respond to standard MQTT requests (in my case: MPRSx8/Relay_1/Switch 0, MPRSx8/Relay_1/Switch 1, MPRSx8/Relay_2/Switch 0, MPRSx8/Relay_2/Switch 1, etc)
Can any of you coders help out here?
I'm happy to help out with any details around clarifying, if needed.
I believe this is simple to be solved for good...
I'm not so good at programing at all but I conceptually know what needs to be done.
In "_P019_PCF8574.ino" you need to add a function that will take a command from the "%sysname%/%tskname%/%valname%"
and the payload is then either a "1" or "0".
Then the PCF8574 plugin will respond to standard MQTT requests (in my case: MPRSx8/Relay_1/Switch 0, MPRSx8/Relay_1/Switch 1, MPRSx8/Relay_2/Switch 0, MPRSx8/Relay_2/Switch 1, etc)
Can any of you coders help out here?
I'm happy to help out with any details around clarifying, if needed.
- budman1758
- Normal user
- Posts: 301
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: (Solved) MQTT (OpenHAB, HA and any standard) cannot control Virtual GPIO's (PCF8574)?
I would suggest you post your request as an issue on Github.
https://github.com/letscontrolit/ESPEasy/issues
https://github.com/letscontrolit/ESPEasy/issues
"The glass is twice as big as it needs to be".
Re: (Solved) MQTT (OpenHAB, HA and any standard) cannot control Virtual GPIO's (PCF8574)?
I have the same problem you describing here.
What did you put into the Rules of the ESPeasy?
Thanx in advance!
Kirelam
What did you put into the Rules of the ESPeasy?
Thanx in advance!
Kirelam
Who is online
Users browsing this forum: No registered users and 0 guests