Page 1 of 5
Creating my own OTGW firmware for the NodoShop version
Posted: Sun Jan 19, 2020 2:19 pm
by rvdbreemen
Hi all,
I started with the nodo shop version of the OTGW hardware. I noticed that it uses the Easyesp firmware as s ser2net server with WD control from the easyesp. This got me thinking it should be possible to create OTGW firmware running on the NodeMcu 8266 hardware running on this gateway. After playing around I got the basics running already. Feeding the watchdog and listening to the serial output of the PIC.
I was just wondering if someone else already did this? So far I have been able to find another projects like the OT Adaptor and some related projects. But then they are not talking to the PIC from Bron Schelte but are directly implementing all interfacing.
My goal is simple, to have an OTGW firmware with the following features:
- standalone wifi OTGW device (nodoshop)
- outputs MQTT messages (monitor mode)
- controlled thru MQTT message (control mode)
- a RESTfull API to listen and control
- local logging on the NodeMCU
So I have three questions for this community:
1. Is there anyone interested to a standalone OTGW with these features?
2. Did I miss any existing projects that already did this?
3. What features would you want to see?
And yes, I know both domoticz and home assistant have a local serial2net based interpreter that works fine. I have been running that for a long time, just in my mind if we have such a powerful 8266 near the source, why not use that better. Plus I want to have it myself...
Looking forward to some responses,
Robert
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Sun Jan 19, 2020 11:25 pm
by hvxl
I've had a similar idea a while ago, triggered by requests for features that simply won't fit in the limited memory of the PIC. To be able to add new features, the PIC would need to run (a possibly modified version of) the interface firmware rather than the normal gateway firmware.
I did some experimenting as well and got the translation of hex messages to human readable form working. I'm afraid local logging on the NodeMCU may not be feasible. If stored in memory, it requires a lot of RAM. And SPIFFS isn't really able to handle the frequent updates. That would wear out the EEPROM memory rather quickly. Unless you are thinking about some other form of logging than individual messages.
I didn't mention anything about these ideas so far because it may be a long time before I have something usable, if I ever get to that point. So I am interested to see what you come up with.
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Tue Jan 21, 2020 11:14 pm
by raga
Please check:
https://github.com/martenjacobs/py-otgw-mqtt
it may address several functionalities you mentioned.
r
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Wed Jan 22, 2020 5:56 pm
by hvxl
Checking the documentation of that project, it seems that it just re-implements one of the many features that is already available in OTmonitor. And it doesn't do any of it in the NodeMCU of the NodoShop version of the OTGW. So I fail to see the relevance to this subject.
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Tue May 05, 2020 8:53 pm
by erikg
@rvdbreemen, I am very interested in your efforts to use the power of the NodeMCU.
Ideally, I would like (a) the control loops for regulating the heat to run standalone on the OTGW FW, and (b) the NodeMCU to offer a simple interface to read the variables (e.g. boiler temperature) and write control settings. The serial interface between the NodeMCU and OTMonitor on my Raspberry Pi works fine but sometimes hangs after a power cycle of the OTGW/NodeMCU.
For (a) I just modifed the assembler FW in the OTGW to add an outside-temperature-dependent maximum-boiler-temperature to reduce temperature fluctuations in some of the rooms. See
viewtopic.php?f=75&t=12774
For (b) I would be looking for read and write control similar to what OTMonitor already offers but without OTMonitor in between:
- Read ---> http://<ip-nodemcu>:<port>/json --> respond with simple json with snapshot of values of all variables
- Write ---> http://<ip-nodemcu>:<port>/command?PR=G --> pass command to OTGW and respond with OTGW response, in my case PR: G=27
This way the interface to other home automation scripts does not rely on a continuous stream of serial communication through a telnet session (which is what serial2net does) that is susceptible to interruptions.
Do you have something similar in place?
Or something that can serve as a starting point?
Thanks,
Erik
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Fri Aug 07, 2020 3:46 pm
by FransO
I cut the Opentherm Monitor out of the loop by running Tasmota on the NodeMCU as a serial to MQTT bridge. Which Tasmota can do out of the box. I cut down on communication overhead by issuing the PS=1 command to the OTGW every minute. The response to this command summarizes the status of all relevant OTGW data. This response is automatically send out by Tasmota via MQTT. I had some stability problems with the NodeMCU inserted in the socket of the OGTW. I finally solved them by cutting some unused pins from the NodeMCU.
Controlling the OTGW on the NodeMCU under Tasmota is more difficult and requires writing scripts. I decode the response in Home Assistant and populate a sensor with the data. Controlling, setting setpoints, can also be done in Home Assistant by issuing a SerialSend command to the NodeMCU via MQTT.
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Thu Aug 13, 2020 3:13 pm
by erikl_
rvdbreemen wrote:1. Is there anyone interested to a standalone OTGW with these features?
Yes, very much so.
rvdbreemen wrote:2. Did I miss any existing projects that already did this?
Unfortunately I couldn't find any.
rvdbreemen wrote:3. What features would you want to see?
Exactly what you mentioned. I want my HVAC reporting status to MQTT via wifi, and able to control it through MQTT as well.
Can you share if you have managed to create a usable version that I can already purchase? Because I would be very interested.
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Fri Aug 14, 2020 12:14 pm
by FransO
As stated in my previous post, I report via MQTT directly from the NodeMCU on the Nodo-shop Opentherm Gateway to my Home Assistant installation. I use Tasmota (
https://tasmota.github.io/docs/#/Home) on the NodeMCU which has all required functionality already built-in. All that was necessary was to configure the serial port and the reset line and to specify two rules. One rule to initialize the system on boot and one to report the status of the OpenTherm Gateway every minute. As stated before I use the response to the PS=1 command to report the status. Much easier than processing each individual message from the gateway. Issuing commands to the gateway can be done from Home Assistant by publishing a serialsend command via MQTT.
The configuration template is:
template {"NAME":"OTGW","GPIO":[255,148,255,149,255,255,255,255,255,255,21,255,56],"FLAG":15,"BASE":18}
The rules are:
rule1 ON system#boot DO backlog power1 0; baudrate 9600; delay 10; power1 1; delay 10; serialsend3 \r; delay 10; serialsend3 GW=R\r; delay 10; serialsend3 PS=1\r ENDON
rule2 ON Time#Minute|1 DO SerialSend3 PS=1\r ENDON
In Home Assistant I use an MQTT sensor to receive the response and a template sensor to decode the response into status information
Code: Select all
- platform: mqtt
name: OpenTherm Gateway
availability_topic: "tele/tasmota-cv/LWT"
payload_available: "Online"
payload_not_available: "Offline"
state_topic: tele/tasmota-cv/RESULT
value_template: "{{ value_json.SerialReceived }}"
icon: mdi:radiator
- platform: template
sensors:
opentherm:
friendly_name: Opentherm OTGW
entity_id: sensor.opentherm_gateway
availability_template: >-
{{ states('sensor.opentherm_gateway')[0] == 'P' }}
icon_template: mdi:radiator
value_template: >-
{% if states('sensor.opentherm_gateway')[23] == '1' %}
Fout
{% else %}
OK
{% endif %}
attribute_templates:
cv_aan: >-
{% if states('sensor.opentherm_gateway')[14] == '1' %}
Ja
{% else %}
Nee
{% endif %}
ww_aan: >-
{% if states('sensor.opentherm_gateway')[13] == '1' %}
Ja
{% else %}
Nee
{% endif %}
cv_actief: >-
{% if states('sensor.opentherm_gateway')[22] == '1' %}
Actief
{% else %}
Uit
{% endif %}
ww_actief: >-
{% if states('sensor.opentherm_gateway')[21] == '1' %}
Actief
{% else %}
Uit
{% endif %}
brander: >-
{% if states('sensor.opentherm_gateway')[20] == '1' %}
Actief
{% else %}
Uit
{% endif %}
cv_instelling: >-
{{ states('sensor.opentherm_gateway').split(',')[5] }}
kamer_temperatuur: >-
{{ states('sensor.opentherm_gateway').split(',')[8] }}
cv_water_instelling: >-
{{ states('sensor.opentherm_gateway').split(',')[1] }}
cv_water_temperatuur: >-
{{ states('sensor.opentherm_gateway').split(',')[9] }}
ww_temperatuur: >-
{{ states('sensor.opentherm_gateway').split(',')[10] }}
buiten_temperatuur: >-
{{ states('sensor.opentherm_gateway').split(',')[11] }}
ww_regelbereik: >-
{{ states('sensor.opentherm_gateway').split(',')[13] }}
cv_regelbereik: >-
{{ states('sensor.opentherm_gateway').split(',')[14] }}
ww_instelling: >-
{{ states('sensor.opentherm_gateway').split(',')[15] }}
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Fri Oct 23, 2020 2:02 am
by rvdbreemen
Wauw, time has gone by fast this crazy year. When I posted I had my first OTGW firmware running that received serial from the PIC and forwarded it on the telnet port.
So I got back to working on this firmware this last week, decoding the OT specification has been implemented.
Once I get MQTT working I will release an alpha for feedback from you guys.
Thanks,
Robert
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Fri Oct 23, 2020 2:05 am
by rvdbreemen
FransO wrote:Tasmota via MQTT
Cool solution, did not explore that myself too much. Since I plan to write a specific firmware just with a single purpose.
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Fri Oct 23, 2020 2:06 am
by rvdbreemen
erikl_ wrote:Can you share if you have managed to create a usable version that I can already purchase? Because I would be very interested.
Sorry that it toke this long. I need to cleanup the firmware, but then I can release and we can start to iterate on it.
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Fri Oct 23, 2020 2:11 am
by rvdbreemen
hvxl wrote:Unless you are thinking about some other form of logging than individual messages.
...
So I am interested to see what you come up with.
So... logging of individual messages to the local SPIFF is no feasible. So I have two options:
1. Logging to MQTT
2. Logging to Influx
I think I will enable both.
My code is done to the point that I need to cleanup code, hook up my MQTT and JSON code, and add InfluxDB client code, and then it should be release as a v0.0.1 to the public.
Robert
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Mon Oct 26, 2020 1:37 am
by rvdbreemen
So playing around with my OTGW firmware. It's working, not ready for release just yet. But you can follow my progress here:
https://github.com/rvdbreemen/OTGW-firmware
Since I started last week I have:
- parsing of OT protocol version 2.2
- debug/telnet mode
- MQTT messages
- Auto-configuration for HomeAssistant (and Domoticz)
There is lot's to do, still planning:
- adding InfluxDB client for easy logging
- REST API for more integration options
- implement more UI
Any feedback, testing and/or ideas on what to do are welcome,
Enjoy,
Robert
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Mon Dec 07, 2020 6:30 pm
by hvxl
Since you asked for ideas: How about adding a web page that allows the user to define a schedule? The NodeMCU would then send TC commands at the specified times to change the thermostat setpoint. One of my friends would appreciate such functionality.
Re: Creating my own OTGW firmware for the NodoShop version
Posted: Sat Dec 12, 2020 3:26 am
by rvdbreemen
hvxl wrote:Since you asked for ideas: How about adding a web page that allows the user to define a schedule? The NodeMCU would then send TC commands at the specified times to change the thermostat setpoint. One of my friends would appreciate such functionality.
Sounds doable, I will put it on the list. Hopefully a good front-ender will help me out with designing a great dashboard webpage.