Achronite / mqtt-energenie-ener314rt

MQTT interface for Energenie ENER314-RT add-on board for the Raspberry Pi, designed for use by Home Assistant.
MIT License
13 stars 5 forks source link

config.json "monitoring": false issue #82

Closed Tempura-so closed 5 months ago

Tempura-so commented 5 months ago

I am trying out mqtt-energenie-ener314rt via the command line, for example :-

mosquitto_pub -h 192.xxx.xxx.xxx -p 1883 -q 2 -t eng/ook/504718/1/command -m "on".

I am only able to successfully transmit the on/off signal when the config.json is set to "monitoring": true

Achronite commented 5 months ago

mosquitto_pub -h 192.xxx.xxx.xxx -p 1883 -q 2 -t eng/ook/504718/1/command -m "on".

Should this be energenie/ook/504718/1/command?

I am only able to successfully transmit the on/off signal when the config.json is set to "monitoring": true

The monitoring: true is only used for receiving messages from the devices that send radio reponses (the energenie 'pink' and 'purple' devices). The blue/green plugs are 'receive only'; so the code transmits to them and then assumes the message has been received successfully by setting the state to 'ON'. So:

energenie/ook/504718/1/command/ON should return energenie/ook/504718/1/state/ON

Don't forget to put your device into pairing mode for the first transmission to teach the code.

Tip: modify the log_level in the config file to verbose if you are having difficulties, you should see it receiving MQTT commands.

Achronite commented 5 months ago

Ah - I think you may have found a bug, in that discovery is still called if the discovery_prefix is there.

Remove the 'discovery_prefix' line in your config.json file as a workaround; i'll fix this now.

Tempura-so commented 5 months ago

Thank you, for your quick response!!

I have removed the 'discovery_prefix' line in the config.json, but unfortunately the same issue occurs

{ "topic_stub": "energenie/", "mqtt_broker": "mqtt://192.168.241.121:1883", "mqtt_options": { "clean": true }, "monitoring": false, "ook_xmits": 10, "fsk_xmits": 5, "log_level": "verbose" }

mosquitto_pub -h 192.xxx.xxx.xxx -p 1883 -q 2 -t energenie/ook/504718/1/command -m "on"

unfortunately the mosquitto_pub command only works when the config.json is set to "monitoring": true,

Achronite commented 5 months ago

It works with MQTT explorer. Can you post a log file for me?

Tempura-so commented 5 months ago

I'm on a raspberry pi 4 model B with 32bit Rasberry pi OS

terminal one

mosquitto_sub -h 192.168.241.121 -p 1883 -t 'energenie/'

terminal two node app.js

terminal three I enter the these two commands

mosquitto_pub -h 192.168.241.121 -p 1883 -q 2 -t energenie/ook/504718/1/command -m "ON"

mosquitto_pub -h 192.168.241.121 -p 1883 -q 2 -t energenie/ook/504718/1/command -m "OFF"

config.json { "topic_stub": "energenie/", "mqtt_broker": "mqtt://192.168.241.121:1883", "mqtt_options": { "clean": true }, "monitoring": true, "ook_xmits": 10, "fsk_xmits": 5, "log_level": "verbose" }

mqtt-energenie-ener314rt version 0.6.0: starting mqtt-ener314rt info MQTT connecting to broker mqtt://192.168.241.121:1883 mqtt-ener314rt info monitor starting monitoring of FSK devices... mqtt-ener314rt verb MQTT connected to broker "mqtt://192.168.241.121:1883" mqtt-ener314rt http MQTT setting availability topic energenie/availability/state to 'online' mqtt-ener314rt verb < energenie/board/1/initialised/state: 1708281751 (board) mqtt-ener314rt verb < energenie/board/1/discover/state: 0 (board) mqtt-ener314rt WARN discovery discovery disabled mqtt-ener314rt info MQTT subscribed to energenie/+/+/+/command mqtt-energenie info energenie child process started ener314rt: Cannot open /dev/spidev0.1 - Fallback to Software SPI driver mqtt-energenie info energenie ENER314-RT initialised succesfully mqtt-energenie verb energenie cmd: {"cmd":"monitor","enabled":true} mqtt-energenie info energenie monitoring thread started mqtt-energenie verb energenie received="{\"deviceId\":14267,\"mfrId\":4,\"productId\":2,\"timestamp\":1708281755,\"REAL_POWER\":19,\"REACTIVE_POWER\":-1,\"VOLTAGE\":249,\"FREQUENCY\":49.800781,\"SWITCH_STATE\":1}" mqtt-ener314rt http monitor received: {"deviceId":14267,"mfrId":4,"productId":2,"timestamp":1708281755,"REAL_POWER":19,"REACTIVE_POWER":-1,"VOLTAGE":249,"FREQUENCY":49.800781,"SWITCH_STATE":1,"cmd":"monitor"} mqtt-ener314rt verb < energenie/2/14267/last_seen/state: 1708281755 mqtt-ener314rt verb < energenie/2/14267/REAL_POWER/state: 19 mqtt-ener314rt verb < energenie/2/14267/REACTIVE_POWER/state: -1 mqtt-ener314rt verb < energenie/2/14267/VOLTAGE/state: 249 mqtt-ener314rt verb < energenie/2/14267/FREQUENCY/state: 49.800781 mqtt-ener314rt verb < energenie/2/14267/switch/state: ON mqtt-ener314rt verb > energenie/ook/504718/1/command: ON mqtt-ener314rt http command {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true} mqtt-ener314rt http monitor received: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true,"state":true} mqtt-ener314rt verb < energenie/ook/504718/1/state: ON (retained) mqtt-ener314rt verb > energenie/ook/504718/1/command: OFF mqtt-ener314rt http command {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false} mqtt-ener314rt http monitor received: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false,"state":false} mqtt-ener314rt verb < energenie/ook/504718/1/state: OFF (retained) mqtt-energenie verb energenie received="{\"deviceId\":14267,\"mfrId\":4,\"productId\":2,\"timestamp\":1708281766,\"REAL_POWER\":19,\"REACTIVE_POWER\":-1,\"VOLTAGE\":249,\"FREQUENCY\":49.800781,\"SWITCH_STATE\":1}" mqtt-ener314rt http monitor received: {"deviceId":14267,"mfrId":4,"productId":2,"timestamp":1708281766,"REAL_POWER":19,"REACTIVE_POWER":-1,"VOLTAGE":249,"FREQUENCY":49.800781,"SWITCH_STATE":1,"cmd":"monitor"} mqtt-ener314rt verb < energenie/2/14267/last_seen/state: 1708281766 mqtt-ener314rt verb < energenie/2/14267/REAL_POWER/state: 19 mqtt-ener314rt verb < energenie/2/14267/REACTIVE_POWER/state: -1 mqtt-ener314rt verb < energenie/2/14267/VOLTAGE/state: 249 mqtt-ener314rt verb < energenie/2/14267/FREQUENCY/state: 49.800781 mqtt-ener314rt verb < energenie/2/14267/switch/state: ON ^Cmqtt-ener314rt WARN app received "SIGINT" signal mqtt-ener314rt info MQTT setting energenie/availability/state to 'offline' mqtt-energenie info energenie signal "SIGINT", closing adaptor and monitoring thread... mqtt-ener314rt verb < energenie/board/1/initialised/state: undefined (board) mqtt-ener314rt info app awaiting shutdown of energenie process... mqtt-ener314rt WARN MQTT Disconnected from MQTT broker: mqtt://192.168.241.121:1883 ^Cmqtt-ener314rt WARN app received "SIGINT" signal mqtt-ener314rt info MQTT setting energenie/availability/state to 'offline'

config.json { "topic_stub": "energenie/", "mqtt_broker": "mqtt://192.168.241.121:1883", "mqtt_options": { "clean": true }, "monitoring": false, "ook_xmits": 10, "fsk_xmits": 5, "log_level": "verbose" }

$ node app.js mqtt-energenie-ener314rt version 0.6.0: starting mqtt-ener314rt info MQTT connecting to broker mqtt://192.168.241.121:1883 mqtt-ener314rt verb MQTT connected to broker "mqtt://192.168.241.121:1883" mqtt-ener314rt http MQTT setting availability topic energenie/availability/state to 'online' mqtt-ener314rt verb < energenie/board/1/initialised/state: 1708281883 (board) mqtt-ener314rt verb < energenie/board/1/discover/state: 0 (board) mqtt-ener314rt WARN discovery discovery disabled mqtt-ener314rt info MQTT subscribed to energenie/+/+/+/command mqtt-energenie info energenie child process started ener314rt: Cannot open /dev/spidev0.1 - Fallback to Software SPI driver mqtt-energenie info energenie ENER314-RT initialised succesfully mqtt-ener314rt verb > energenie/ook/504718/1/command: ON mqtt-ener314rt http command {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true} mqtt-ener314rt http monitor received: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true,"state":true} mqtt-ener314rt verb < energenie/ook/504718/1/state: ON (retained) mqtt-ener314rt verb > energenie/ook/504718/1/command: OFF mqtt-ener314rt http command {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false} mqtt-ener314rt http monitor received: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false,"state":false} mqtt-ener314rt verb < energenie/ook/504718/1/state: OFF (retained) mqtt-ener314rt verb > energenie/ook/504718/1/command: ON mqtt-ener314rt http command {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true} mqtt-ener314rt http monitor received: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":true,"state":true} mqtt-ener314rt verb < energenie/ook/504718/1/state: ON (retained) mqtt-ener314rt verb > energenie/ook/504718/1/command: OFF mqtt-ener314rt http command {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false} mqtt-energenie verb energenie cmd: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false} mqtt-ener314rt http monitor received: {"cmd":"send","mode":"ook","repeat":10,"zone":"504718","switchNum":"1","switchState":false,"state":false} mqtt-ener314rt verb < energenie/ook/504718/1/state: OFF (retained)

I have even tried the app.js in examples https://github.com/Achronite/energenie-ener314rt and it only works if you keep function startMonitoringThread()

hope this helps

Achronite commented 5 months ago

So are you saying it received the command ok but the plug didn't switch?

Tempura-so commented 5 months ago

yes, but the strange thing is that the ener314-rt still lights up red (LED2) and nothing happens until "monitoring": true

Achronite commented 5 months ago

Ok I'll look into it tomorrow.

Are you running v0.6?

Tempura-so commented 5 months ago

Yes v0.6

I've be using https://github.com/whaleygeek/pyenergenie on my raspberry pi 4 I'm transitioning to a raspberry pi 5 so I know that yours is moving into that direction.

Achronite commented 5 months ago

Above issue#43 has been fixed in develop branch of dependent module

Tempura-so commented 5 months ago

I have tested out energenie-ener314rt module via the develop branch and it is working nicely, thank you.

Achronite commented 5 months ago

Glad to see this has fixed it for you, although I see you have a Smart Plug+, so you would benefit from monitoring: true.

BTW: If you are looking to run this on a Pi 5 you will need to switch to the hardware SPI driver.

Tempura-so commented 5 months ago

BTW: If you are looking to run this on a Pi 5 you will need to switch to the hardware SPI driver.

Yes, that is definitely the plan to switch to the [hardware SPI driver]