Hi Glyn, I am confused as to where/how to access the zigbeemqtt frontend from the emonPi (as there is no browser installed). I have successfully set up a standalone RaspberryPi with zigbee2mqtt and am now trying to do the same on an emonPi, but stumped as to how to access the zigbeemqtt frontend.
Your help is greatly appreciated.
You should be able to access the front end on port 8080 either using hostname lookup which should work on most networks assuming there’s only one emonPi in the network http://emonpi.local:8080, or by replacing emonpi.local with the IP address of the emonpi e.g http://192.168.1.32:8080
You’ll need to be connected to the same local network as the emonPi
I’ve tried both emonpi.local:8080 and the IP address with the same result. Both the pi and my computer are on the same network. I can ssh into the pi without issue
I enabled the front end in the configuration.yaml file and it uses port 8080 by default.
Can you access the emonPi Emoncms interface on port 80? via http://emonpi.local or via the IP address?
If so, the issue must be with zigbee2mqtt. Try looking at the log files?
You could try making sure the port is open on the firewall with
sudo ufw allow 8080
I can access emonpi emoncms with http://emonpi.local and IP:80.
The command above did not resolve the issue.
So, back to zigbee2mqtt to find the issue.
thanks for the help.
I notice the MQTT section of the config you posted above should be using the localhost ip address i.e server: mqtt://127.0.0.1
if you want it to connect to the emonPi internal MQTT server
finally figured it out after looking at each character. I had an apostrophe (') in front of the 127.0.0.1 - always something stupid.
I am getting closer, but I am not seeing any inputs in emonCMS on the emonPi. It feels like I am missing a step. To avoid any confusion or potential conflicts, I am using an emonBase without any CT clamps, probes, or any 433Mhz devices attached. It is basically a RaspberryPi with the emon and zigbee2MQTT apps running.
One other thing. I could not get the Sonoff USB stick to work. So I switched to the ConBee II which shows up as /dev/ttyAMA0
. This seems to work quite well. Does this create any conflict with emon?
I can connect to the Zigbee2MQTT dashboard and see my 3 test devices in the Zigbee dashboard.
I have made the changes to emonHub but do not see anything on the inputs page. I know that I am connected to MQTT in the emonhub log
[[MQTT]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/temp1
From emonHub log
2024-08-11 23:09:40,456 INFO MainThread EmonHub v2.5.5
2024-08-11 23:09:40,457 INFO MainThread Opening hub...
2024-08-11 23:09:40,457 INFO MainThread Running as user: pi
2024-08-11 23:09:40,457 INFO MainThread Logging level set to DEBUG
2024-08-11 23:09:40,458 INFO MainThread Creating EmonHubOEMInterfacer 'EmonPi2'
2024-08-11 23:09:40,458 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 115200 bits/s
2024-08-11 23:09:40,459 INFO MainThread Creating EmonHubOEMInterfacer 'USB0'
2024-08-11 23:09:40,460 ERROR MainThread Could not open serial port: /dev/ttyUSB0 @ 115200 bits/s (retry every 10s)
2024-08-11 23:09:40,460 INFO MainThread Creating EmonHubRFM69LPLInterfacer 'SPI'
2024-08-11 23:09:40,461 ERROR MainThread Unable to create 'SPI' interfacer: EmonHubRFM69LPLInterfacer.__init__() got an unexpected keyword argument 'resetPin'
2024-08-11 23:09:40,461 INFO MainThread Creating EmonHubMqttInterfacer 'MQTT'
2024-08-11 23:09:40,461 DEBUG MainThread Setting MQTT pubchannels: ['ToEmonCMS']
2024-08-11 23:09:40,462 INFO MainThread Setting MQTT node_JSON_enable: 1
2024-08-11 23:09:40,462 INFO MainThread Setting MQTT node_JSON_basetopic: zigbee2mqtt/temp1
2024-08-11 23:09:40,462 INFO MQTT Connecting to MQTT Server
2024-08-11 23:09:40,462 INFO MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2024-08-11 23:09:40,464 DEBUG MainThread Setting emoncmsorg interval: 30
2024-08-11 23:09:40,464 DEBUG MainThread Setting emoncmsorg pubchannels: ['ToRFM12']
2024-08-11 23:09:40,464 DEBUG MainThread Setting emoncmsorg subchannels: ['ToEmonCMS']
2024-08-11 23:09:40,464 WARNING MainThread Setting emoncmsorg apikey: obscured
2024-08-11 23:09:40,465 INFO MainThread Setting emoncmsorg url: https://emoncms.org
2024-08-11 23:09:40,465 INFO MainThread Setting emoncmsorg senddata: 1
2024-08-11 23:09:40,465 INFO MainThread Setting emoncmsorg sendstatus: 0
2024-08-11 23:09:40,465 INFO MainThread Setting emoncmsorg sendnames: 1
2024-08-11 23:09:40,465 INFO MainThread Setting emoncmsorg compress: 0
2024-08-11 23:09:40,466 INFO MainThread Creating EmonHubDS18B20Interfacer 'DS18B20'
2024-08-11 23:09:40,481 INFO MainThread Setting DS18B20 read_interval: 10
2024-08-11 23:09:40,481 INFO MainThread Setting DS18B20 nodename: sensors
2024-08-11 23:09:40,481 INFO MainThread Setting DS18B20 ids:
2024-08-11 23:09:40,481 INFO MainThread Setting DS18B20 names:
2024-08-11 23:09:40,482 DEBUG MainThread Setting DS18B20 pubchannels: ['ToEmonCMS']
2024-08-11 23:09:40,482 DEBUG MainThread Automatic configuration of nodes enabled
2024-08-11 23:09:40,565 INFO MQTT connection status: Connection successful
2024-08-11 23:09:40,565 INFO MQTT subscribe 1
2024-08-11 23:09:40,566 DEBUG MQTT CONACK => Return code: 0
2024-08-11 23:09:40,767 DEBUG MQTT on_subscribe
Nice work, have you switched to the mqtt_subscribe
emonhub branch? This is needed to enable emonHub to subscribe to the JSON MQTT data, this has not yet been merged into emonhub master branch:
You can switch by mqtt_suscribe
branch with
cd /opt/openenergymonitor/emonhub
git pull
git checkout mqtt_subscribe
You’ll need to add the following to emonhub.conf
to get it to subscribe to a zigbee MQTT json topic:
[[MQTT_sub]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/temp
Replace temp
with the name of your sensor. You can use MQTT Explorer to see what the MQTT data looks like on your emonPi.
Ahh. I figured I was missing a step. Will tackle this next.
I have 3 sensors. Do I configure like this?
node_JSON_enable = 3
And then
node_JSON_basetopic = zigbee2mqtt/temp
node_JSON_basetopic = zigbee2mqtt/aqi
node_JSON_basetopic = zigbee2mqtt/leak
Is the sensor name the same as “friendly name” used in zugbee2mqtt?
Thanks,
Gordon
I’m not sure about 3 sensors, I’ve only tested with one. Can you get one sensor working first? Then we can figure out how to add the other two.
You may need multiple instances of mqtt-sub e.g
[[MQTT_sub_temp]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/temp
[[MQTT_sub_aqi]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/aqi
[[MQTT_sub_leak]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/leak
I’ve not tested this, so first try with one instance. Do you think this will work @TrystanLea ?
Sounds good. I will keep you updated.
Btw I never could get the Docket method to work so I used the Linux install method.
Hi Glyn,
I am subscribed to zigbeeMQTT topic (looks like I was already), but still do not see anything on the inputs screen of emonCMS. I think I am very close as I do see the data in the emonhub log. For some reason it is not creating the node on the emonCMS inputs screen.
2024-08-12 19:32:12,489 DEBUG MQTT_sub Received topic:zigbee2mqtt/Office Temp_Humid
2024-08-12 19:32:12,490 DEBUG MQTT_sub Received payload:{"battery":100,"humidity":45.1,"linkquality":255,"temperature":30}
2024-08-12 19:32:12,490 DEBUG MQTT_sub 20 Sent to channel' : ToEmonCMS
2024-08-12 19:32:12,686 DEBUG emoncmsorg Buffer size: 1
After making the changes below, I looked at the emonHub log and noticed a couple of error messages. I am unsure if they are applicable as the USB device I am using is showing up as serial port: /dev/ttyAMA0.
2024-08-12 19:11:49,099 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 115200 bits/s
2024-08-12 19:11:49,099 INFO MainThread Creating EmonHubOEMInterfacer 'USB0'
2024-08-12 19:11:49,100 ERROR MainThread Could not open serial port: /dev/ttyUSB0 @ 115200 bits/s (retry every 10s)
2024-08-12 19:11:49,101 INFO MainThread Creating EmonHubRFM69LPLInterfacer 'SPI'
2024-08-12 19:11:49,101 ERROR MainThread Unable to create 'SPI' interfacer: EmonHubRFM69LPLInterfacer.__init__() got an unexpected keyword argument 'resetPin'
And I have made the changes to emonHub as shown below.
[[MQTT_sub]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/Office Temp_Humid
When I look at the data being published, it is as shown below.
[2024-08-12 19:12:38] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/bridge/config', payload '{"commit":"e132316","coordinator":{"meta":{"maintrel":0,"majorrel":38,"minorrel":114,"product":0,"revision":"0x26720700","transportrev":0},"type":"ConBee2/RaspBee2"},"log_level":"info","network":{"channel":11,"extendedPanID":"0x13415ff11ca3a005","panID":16128},"permit_join":true,"version":"1.39.1"}'
[2024-08-12 19:12:38] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Office Temp_Humid', payload '{"battery":100,"humidity":46.1,"linkquality":255,"temperature":30}'
[2024-08-12 19:12:38] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Office Air Quality', payload '{"air_quality":"good","battery":100,"humidity":45.3,"linkquality":255,"temperature":29.9,"update":{"installed_version":262145,"latest_version":262145,"state":"idle"},"update_available":false,"voc":549,"voltage":3100}'
[2024-08-12 19:12:38] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Office Water Leak', payload '{"battery":94}'
Lastly, here is the full log from lemon
2024-08-12 19:28:59,192 INFO MainThread Creating EmonHubRFM69LPLInterfacer 'SPI'
2024-08-12 19:28:59,193 ERROR MainThread Unable to create 'SPI' interfacer: EmonHubRFM69LPLInterfacer.__init__() got an unexpected keyword argument 'resetPin'
2024-08-12 19:28:59,194 INFO MainThread Setting MQTT_sub node_JSON_basetopic: zigbee2mqtt/Office Temp_Humid
2024-08-12 19:28:59,194 INFO MainThread Setting emoncmsorg senddata: 1
2024-08-12 19:28:59,194 INFO MainThread Setting emoncmsorg sendnames: 1
2024-08-12 19:28:59,195 INFO MainThread Setting DS18B20 read_interval: 10
2024-08-12 19:29:06,767 DEBUG MainThread Signal 15 received.
2024-08-12 19:29:06,842 INFO MainThread Exiting hub...
2024-08-12 19:29:07,081 INFO MainThread Exit completed
2024-08-12 19:29:07,687 INFO MainThread EmonHub v2.5.5
2024-08-12 19:29:07,687 INFO MainThread Opening hub...
2024-08-12 19:29:07,687 INFO MainThread Running as user: pi
2024-08-12 19:29:07,688 INFO MainThread Logging level set to DEBUG
2024-08-12 19:29:07,688 INFO MainThread Creating EmonHubOEMInterfacer 'EmonPi2'
2024-08-12 19:29:07,689 DEBUG MainThread Opening serial port: /dev/ttyAMA0 @ 115200 bits/s
2024-08-12 19:29:07,689 INFO MainThread Creating EmonHubOEMInterfacer 'USB0'
2024-08-12 19:29:07,690 ERROR MainThread Could not open serial port: /dev/ttyUSB0 @ 115200 bits/s (retry every 10s)
2024-08-12 19:29:07,691 INFO MainThread Creating EmonHubRFM69LPLInterfacer 'SPI'
2024-08-12 19:29:07,691 ERROR MainThread Unable to create 'SPI' interfacer: EmonHubRFM69LPLInterfacer.__init__() got an unexpected keyword argument 'resetPin'
2024-08-12 19:29:07,691 INFO MainThread Creating EmonHubMqttInterfacer 'MQTT_sub'
2024-08-12 19:29:07,692 DEBUG MainThread Setting MQTT_sub pubchannels: ['ToEmonCMS']
2024-08-12 19:29:07,692 INFO MainThread Setting MQTT_sub node_JSON_enable: 1
2024-08-12 19:29:07,692 INFO MainThread Setting MQTT_sub node_JSON_basetopic: zigbee2mqtt/Office Temp_Humid
2024-08-12 19:29:07,692 INFO MQTT_sub Connecting to MQTT Server
2024-08-12 19:29:07,692 INFO MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2024-08-12 19:29:07,694 DEBUG MainThread Setting emoncmsorg interval: 30
2024-08-12 19:29:07,694 DEBUG MainThread Setting emoncmsorg pubchannels: ['ToRFM12']
2024-08-12 19:29:07,694 DEBUG MainThread Setting emoncmsorg subchannels: ['ToEmonCMS']
2024-08-12 19:29:07,694 WARNING MainThread Setting emoncmsorg apikey: obscured
2024-08-12 19:29:07,695 INFO MainThread Setting emoncmsorg url: https://emoncms.org
2024-08-12 19:29:07,695 INFO MainThread Setting emoncmsorg senddata: 1
2024-08-12 19:29:07,695 INFO MainThread Setting emoncmsorg sendstatus: 0
2024-08-12 19:29:07,695 INFO MainThread Setting emoncmsorg sendnames: 1
2024-08-12 19:29:07,695 INFO MainThread Setting emoncmsorg compress: 0
2024-08-12 19:29:07,696 INFO MainThread Creating EmonHubDS18B20Interfacer 'DS18B20'
2024-08-12 19:29:07,711 INFO MainThread Setting DS18B20 read_interval: 10
2024-08-12 19:29:07,712 INFO MainThread Setting DS18B20 nodename: sensors
2024-08-12 19:29:07,712 INFO MainThread Setting DS18B20 ids:
2024-08-12 19:29:07,712 INFO MainThread Setting DS18B20 names:
2024-08-12 19:29:07,712 DEBUG MainThread Setting DS18B20 pubchannels: ['ToEmonCMS']
2024-08-12 19:29:07,713 DEBUG MainThread Automatic configuration of nodes enabled
2024-08-12 19:29:07,795 INFO MQTT_sub connection status: Connection successful
2024-08-12 19:29:07,795 INFO MQTT_sub subscribe 1
2024-08-12 19:29:07,796 DEBUG MQTT_sub CONACK => Return code: 0
2024-08-12 19:29:07,996 DEBUG MQTT_sub on_subscribe
2024-08-12 19:32:12,489 DEBUG MQTT_sub Received topic:zigbee2mqtt/Office Temp_Humid
2024-08-12 19:32:12,490 DEBUG MQTT_sub Received payload:{"battery":100,"humidity":45.1,"linkquality":255,"temperature":30}
2024-08-12 19:32:12,490 DEBUG MQTT_sub 20 Sent to channel' : ToEmonCMS
2024-08-12 19:32:12,686 DEBUG emoncmsorg Buffer size: 1
2024-08-12 19:34:06,714 DEBUG MQTT_sub Received topic:zigbee2mqtt/Office Temp_Humid
2024-08-12 19:34:06,714 DEBUG MQTT_sub Received payload:{"battery":100,"humidity":45.1,"linkquality":255,"temperature":30}
2024-08-12 19:34:06,715 DEBUG MQTT_sub 32 Sent to channel' : ToEmonCMS
2024-08-12 19:34:06,945 DEBUG emoncmsorg Buffer size: 1
That’s great, it looks like emonhub is successfully subscribing to the zigbee data. I’m not sure why Inputs are nor being created. Are you able to give me remote access? I could try and take a look?
The error Could not open serial port: /dev/ttyUSB0
is because there must be an emonub interfacer trying to connect to a serial device on USB0, but there’s no device connected. You can remove this interfacer to get rid of this error.
Have you got an RFM69 device connected? If not, remove the SPI interfacer from emonHub, this will fix the error. Unable to create 'SPI' interfacer: EmonHubRFM69LPLInterfacer.__init__() got an unexpected keyword argument 'resetPin'
remove
Yes, this will conflict on an emonPi2 with the internal serial port. But it will work fine, on a emonBase as long as the emonPi2 interfacer is removed which will by trying to connect on ttyAMA0
Should I delete this section in emonhub to remove the error?
[[USB0]]
Type = EmonHubOEMInterfacer
[[[init_settings]]]
com_port = /dev/ttyUSB0
com_baud = 115200
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
subchannels = ToRFM12,
nodename = emonTx4
I do not have a RFM69 device so I will delete this section.
How would you like to access remotely?
Also, I’m planning on using a RaspberryPi Zero for this application not the emonPi2.
Glyn, I set up port forwarding so you can remote in. I will send you the info in PM.
yes
Ok great. I only need SSH, no need for HTTP
Hi Trystan and Glyn,
Is there a way to manually add inputs?
As mentioned, I am seeing the data in emonhub
2024-08-15 16:23:30,893 DEBUG MQTT_sub Received topic:zigbee2mqtt/Office Air Quality
2024-08-15 16:23:30,894 DEBUG MQTT_sub Received payload:{"air_quality":"excellent","battery":100,"humidity":35.9,"linkquality":255,"temperature":30.7,"update":{"installed_version":262145,"latest_version":262145,"state":"idle"},"update_available":false,"voc":221,"voltage":3100}
2024-08-15 16:23:30,894 DEBUG MQTT_sub 15320 Sent to channel' : ToEmonCMS
2024-08-15 16:23:43,239 DEBUG emoncmsorg Buffer size: 1
And below are the entries in emonhub config
[[MQTT_sub]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = emonpi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/Office Air Quality
But the Inputs screen is blank
I am at a loss trying to determine how to create the inputs. Please advise.
Thank you,
Gordon
Ok, I’ve had a look at your system and the only thing I can see is that your JSON payload being published by zigbee2mqtt has got two nested JSON items:
{"air_quality":"excellent","battery":100,"humidity":34.3,"linkquality":255,"temperature":32,"update":{"installed_version":262145,"latest_version":262145,"state":"idle"},"update_available":false,"voc":59,"voltage":3100}
While my payload when I tested it was:
{"battery":100,"humidity":80,"temperature":22,"voltage":3100}
Also, your JSON payload contains text values instead of numerical e.g "air_quality":"excellent"
Supporting nested payloads will require dev work on emonhub and Emoncms only supports numerical inputs, I’m afraid I don’t have the time to spend on this now. Zigbee is not something that we officially support.