Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.json "monitoring": false issue #82

Closed
Tempura-so opened this issue Feb 18, 2024 · 13 comments · Fixed by #83
Closed

config.json "monitoring": false issue #82

Tempura-so opened this issue Feb 18, 2024 · 13 comments · Fixed by #83
Labels
done Issue fixed in develop branch
Milestone

Comments

@Tempura-so
Copy link

Tempura-so commented Feb 18, 2024

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

@Tempura-so Tempura-so changed the title config.json "monitoring": false not working config.json "monitoring": false issue Feb 18, 2024
@Achronite
Copy link
Owner

Achronite commented Feb 18, 2024

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
Copy link
Owner

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.

@Achronite Achronite added this to the v0.7.1 milestone Feb 18, 2024
@Achronite Achronite added the done Issue fixed in develop branch label Feb 18, 2024
@Tempura-so
Copy link
Author

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
Copy link
Owner

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

@Tempura-so
Copy link
Author

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
Copy link
Owner

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

@Tempura-so
Copy link
Author

Tempura-so commented Feb 18, 2024

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

@Achronite
Copy link
Owner

Achronite commented Feb 18, 2024

Ok I'll look into it tomorrow.

Are you running v0.6?

@Tempura-so
Copy link
Author

Tempura-so commented Feb 18, 2024

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
Copy link
Owner

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

@Tempura-so
Copy link
Author

Tempura-so commented Feb 19, 2024

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

@Achronite
Copy link
Owner

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
Copy link
Author

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]

@Achronite Achronite mentioned this issue Feb 21, 2024
@Achronite Achronite linked a pull request Feb 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Issue fixed in develop branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants