-
Notifications
You must be signed in to change notification settings - Fork 12
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
How to use only webpage part #9
Comments
Hi, sorry for the late reply in the holiday. Funny that you mention MQTT. I have implemented support for this in ModuleInterface, so that all outputs from all modules are mirrored into moduleinterface/modulename/output/variablename. I am done testing this and am now working on testing of inputs from MQTT to ModuleInterface modules, and bidirectional transfer of settings. This will run in addition to the HTTP transfer to/from the web pages, allowing several systems to be connected. My initial goal with this is to let ModuleInterface systems use functionality (phone notifications, smart switches, ...) in popular systems like Home Assistant, and vica versa. I will release this in some weeks time. Notice my new MQTT client library that I am using to make this portable also to Linux and Windows. I understand that if your devices are battery powered, ModuleInterface may not be the best choice, as it demands some memory and usually does interval based transfers initiated by the master. It does support device-initiated transfers, and the master transfer interval can be increased, but I can see that you may want something very tailored and minimized in the battery powered devices. A ModuleInterface master is communicating with the database behind the web page using HTTP. The code for serializing the values into JSON and posting them to the web server, and getting values from the web server, is in the file named ModuleInterfaceHttpTransfer.h. You can take a look to see how the HTTP requests and JSON are formed. If you can match these requests, you can replace the ModuleInterface master with anything, for example a program picking up values from MQTT and sending them into the database as JSON HTTP posts. And the reverse with settings if needed. Actually, with the new MQTT support that is soon released, along with the existing code for HTTP/JSON requests, I could also make a example that is transferring values/settings between MQTT and the database. This could be useful for archiving input values from external systems like Home Assistant when this is used, as I do. It could be transferring the values one-to-one, so that the value "3.14" of topic sometopic/variablename is transferred to the currentvalues table as variablename=3.14. If you have composite values, like 36/36/596, you could modify the example to parse the values if you need to archive them as individual numbers for plotting. Is this interesting? EDIT: Sorry for the rather long response :-) I see it should have been shorter. |
In case you wish to proceed without waiting, this is the recipe for pushing values into the database.
You can also use the higher level HttpClient to send the JSON payload |
Thank you for yor detailed response.I will be waiting for your code update.This sounds like what I was looking for. Thanks. |
@happytm I recently added support for mirroring outputs and settings to MQTT, with support for bidirectional transfer of settings (change in module itself, MQTT or web page and it will be synced to the other places.). Inputs are also possible to set from MQTT, feeding a module with measurements or status from somewhere else. This transfer is done on an interval basis (10s by default), and I am working on adding event support to let important changes (movement sensor, light switch etc) be transferred immediately to and from MQTT. After the event support is complete I will add functionality that can transfer values from MQTT to the web page / database directly even if there are no modules using the values. |
@happytm Are you still interested in this feature? What I can see the need for even when running a complete ModuleInterface setup is the functionality of picking up values from MQTT topics and sending them to the web server for archival in the database, for plotting purposes primarily, but also for any program doing analysis. This would cover your need as well I guess. I already have support for transferring inputs to modules from MQTT. What about settings for your modules? Would you configure this in the ModuleInterface web page and so would have use for settings from the web page / database being published to the MQTT broker? |
I am working on low power IOT home automation network. The code I wrote send up to 5 different sensor values, their respective sensor types and 5 different status values for that particular device along with the device ID to identify the device. These devices can also receive MQTT commands from any MQTT client by publishing with topic "command/". My repo is linked below:
https://github.com/happytm/BatteryNode
Right now I am using ESP Dash android app to monitor and control my network but your software could be better because it can not only display but store it in database. I have used node-red but I think it is overkill in my case.
I would like to use your front end to display data on web and store it in database. Data will be collected by network of my battery nodes and published as MQTT messages by the gateway. I wanted to see how I can implement my ProbeReceiver.ino sketch with your code and display all sensor data it collects from all battery node devices on network . Each BatteryNode devices send data to one gateway and gateway has MQTT broker built in which publishes data in following format for example data received from a BatteryNode with Device ID = 36:
Serial debug messages on Gateway device where it receive data from all Battery node devices:
Command sent to device no. 36 = 'command/36/06/16/26/36/46/
################ Person 1 arrived ######################
Received Topic 'Sensordata/Person1/Home
Received Topic 'Sensordata/Signal/-48
Received Topic 'Sensordata/Person1/in/Livingroom
Received Topic 'SensorData/36/6/2.90
Received Topic 'SensorData/36/16/20
Received Topic 'SensorData/36/26/50
Received Topic 'SensorData/36/36/596
Received Topic 'SensorData/36/46/37
Received Topic 'DeviceStatus/36/DeviceMode/0
Received Topic 'DeviceStatus/36/DeviceIP/36
Received Topic 'DeviceStatus/36/WiFiChannel/7
Received Topic 'DeviceStatus/36/SleepTime/1
Received Topic 'DeviceStatus/36/UpTime/127
6,16,26,36,46 in above messages are predefined sensor types to identify what kind of sensors they are for example 6 = voltage, 16 = temperature , 26 = humidity, 36 = pressure, 46 = light intensity etc.
Signal Strength of remote sensor: -23
Received Topic 'Sensordata/Signal/-23
Serial debug messages from BatteryNode device no. 36:
Sensor Type values sent to controller: 24:06:10:1A:24:2E
Device status values sent to controller: 24:00:24:07:01:8B
Sensors values sent to controller: 24:93:38:25:19:59
Message received from Controller: 24:06:10:1A:24:2E (This message is received from gateway).
I hope you can help me.
Thanks.
The text was updated successfully, but these errors were encountered: