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

Restructured to platform.io #30

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8d6ec63
Delete unused files
zinen May 29, 2022
4ab4422
Format project for platformIO
zinen May 29, 2022
8a1aa73
Fixed spellings and abreviations
zinen May 29, 2022
074c6c0
Added modbus cooldown and get functions
zinen May 29, 2022
4bb4ce6
MQTT boot msg, update mode and handle retained cmd
zinen May 29, 2022
d0f5a52
Dont read unreadable adresses modbus HMI350T
zinen May 29, 2022
9f7247a
Update docs
zinen May 29, 2022
b95f370
Cleanup
zinen May 29, 2022
f579dcd
Removed unused setting
zinen May 29, 2022
6f8a4d3
Added openhab v1 examples
zinen May 29, 2022
01b10ae
Fix spelling
zinen May 29, 2022
a8296df
Configuration can be in seperate file now
zinen May 30, 2022
c8e6867
[ImgBot] Optimize images
ImgBotApp May 30, 2022
810f498
Removed some read values about effect use
zinen Jun 11, 2022
fe6cc6b
Removed unused info
zinen Jun 12, 2022
4032ab7
Publish ip adress
zinen Jul 7, 2022
b0e6736
Fix for error with HWID stated from platformIO car 6.1.0 (2022-07-06)
zinen Jul 7, 2022
80f0324
Formating camelCase
zinen Jul 7, 2022
315647d
Comamnds now in cmd topic, debug scantime added
zinen Jul 11, 2022
5418044
scantime publish more data
zinen Jul 12, 2022
b82fa24
Merge pull request #1 from zinen/imgbot
zinen Aug 1, 2022
50b7295
Fix some spelling mistakes
zinen Aug 16, 2022
4e3de55
Merge branch 'master' of https://github.com/jascdk/Nilan_Homeassistant
zinen Aug 16, 2022
0501c98
Fixed spelling
zinen Aug 16, 2022
24d2238
Cleanup files
zinen Aug 16, 2022
cf6b411
Spelling
zinen Aug 17, 2022
689f7c8
Spelling
zinen Aug 17, 2022
f58638e
Mainly to support platform.io
zinen Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
secrets.ini
logs/*
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
Binary file removed .vscode/ipch/59a9facdc0666fbe/mmap_address.bin
Binary file not shown.
Binary file removed .vscode/ipch/af4c1ea3071889c8/mmap_address.bin
Binary file not shown.
Binary file removed .vscode/ipch/af4c1ea3071889c8/nilan_code.ipch
Binary file not shown.
Binary file removed .vscode/ipch/ffb8356500484687/mmap_address.bin
Binary file not shown.
Binary file removed .vscode/ipch/ffb8356500484687/nilan_code.ipch
Binary file not shown.
53 changes: 53 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cSpell.words": [
"chipid",
"dtostrf",
"Modbus",
"Openhab",
"platformio"
],
"cSpell.ignoreWords": [
"Gunvald",
"Anders",
"Kvist",
"Scherrebeck",
"Wemos",
"Benoît",
"Blanchon",
"ventset",
"runset",
"modeset",
"tempset",
"programset",
"OVERTEMP",
"LEGIONEL",
"INSTABUS",
"reqtemp",
"reqalarm",
"reqtime",
"reqcontrol",
"reqspeed",
"reqairtemp",
"reqairflow",
"reqairheat",
"reqprogram",
"requser",
"requser2",
"reqinfo",
"reqinputairtemp",
"reqapp",
"reqoutput",
"reqdisplay1",
"reqdisplay2",
"reqdisplay",
"reqmax",
"airtemp",
"airheat",
"inputairtemp",
"Frost_overht",
"SWSERIAL_8E1",
"weekprogram"


]
}
Binary file added CTS602_w_HMI350T_Modbus.pdf
Binary file not shown.
Binary file modified Esphome/nilan_display.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Home Assistant/HA_GUI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Home Assistant/ventilation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Openhab/openhabV1.items
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Switch nilanrun {mqtt=">[my:ventilation/RunSet:command:ON:1],>[my:ventilation/RunSet:command:OFF:0]"}
Number nilanrunstate {mqtt="<[my:ventilation/control/RunSet:state:REGEX(([0-9-]+))]"}
Number nilanmode {mqtt=">[my:ventilation/ModeSet:state::default]"}
Number nilanmodestate {mqtt="<[my:ventilation/control/ModeSet:state:REGEX(([0-9-]+))]"}
Number nilanvent {mqtt=">[my:ventilation/VentSet:state::default]"}
Number nilanventstate {mqtt="<[my:ventilation/control/VentSet:state:REGEX(([0-9-]+))]"}
Number nilantemp {mqtt=">[my:ventilation/TempSet:state::REGEX(([0-9-]+))]"}
Number nilantempstate {mqtt="<[my:ventilation/control/TempSet:state:REGEX(([0-9-]+))]"}
Number nilaninlet "Ventilation indgang temp [%s]" {mqtt="<[my:temp/T7_Inlet:state:REGEX(.?([0-9.]+).]"}
Number nilanoutside "Ventilation ude temp [%s]" {mqtt="<[my:temp/T8_Outdoor:state:REGEX(.?([0-9.]+).*]"}
6 changes: 6 additions & 0 deletions Openhab/openhabv1.sitemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Frame label="Ventilation" {
Switch item=nilanrun label="Tændt"
Selection item=nilanmode label="Funktion" mappings=[0= "Off", "1"="Heat", "2" = "Cool", 3 = "Auto", 4 = "Service"]
Selection item=nilantemp label="Temperatur" mappings=[1900="19", 2200="22", 2500="25"]
Selection item=nilanvent label="Hastighed" mappings=[0="0",1="1",2="2",3="3",4="4"]
}
94 changes: 48 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,91 @@
# Make your Nilan Air ventilating system way more cool ;)
# Unofficial gateway for Nilan ventilation system

This little cool project lets you use you Home Assistant to control and read values from your Nilan air vent system. I have the Nilan Comfort 300 combined with the CTS602 panel. It works great, but do not know if it is compatible with other models.
This little cool project lets you control your Nilan air vent system. Eg. Used with Nilan Comfort 300 LR combined with the CTS602 panel. And should be compatible with other models.

The code for the project is not developed by me, but I made some adjustmenst to it, so it would integrate better with Home Assistant. The project is originally made for use with OpenHab.
Can be used with Openhab, Home Assistant, Node-red or anything else your heart desires.

For the original project look here: https://github.com/DanGunvald/NilanModbus
Easy compile source code via Platform.io setup.

Please proceed this project at your own risk!!!
![SVG preview of system](images/overview.svg)

UPDATE 19/2-2020 : Got the code working with ArduinoJson version 6 (updated from version 5). Version 6 had some big breaking changes.
This is a fork of https://github.com/jascdk/Nilan_Homeassistant mainly made to support platform.io.

UPDATE 1/1-2020 : Now added a .ino file for use with a Nilan VPL15 system. Creates some others sensors over the Comfort 300 system. thanks to Martin Skeem for editing / coding :)
Which in turn is a fork of https://github.com/DanGunvald/NilanModbus

## Okay lets get to it!
# How to use:
You can use this either via MQTT messages or via web request

### Installing the firmware:

I used the arduino editor to upload the code to my ESP8266 (for now a wemos D1 mini). If your sketch wont compile please check if you use the arduino.json V. 5 or V.6 library. This code uses V.6 and wont build with V.5.

For setting up your wifi and mqtt broker provide your credentials in the configuration.h file


### Setup the Hardware:
## Web
You can get some json values from the Nilan by calling to it via HTTP. Just use your browser and type:

For my project i use af Wemos D1 mini board connected to a RS485 board (bought form ali-express). You connect from the Wemos the RX to RX on the RS485 and the TX to TX. This wont work if you cross them.
`http://[ip]/help` - This should give you som registers

Then connect the RS485 A,B and GND channel to the corresponding ports on you Nilan Vent System.
`http://[ip]/read/app` - This would for example give you some status of the output

### Getting values by HTTP:
`http://[ip]/get/[adress]/[amountOfAdresessToRead]/[0=InputRegister(default),1=HoldingRegister]`- This would make you able to read raw data from controller

You can get some json values from the Nilan by calling to it via HTTP. Just use your browser and type:
`http://[ip]/set/[group]/[adress]/[value]`- This would make you able to send commands through HTTP

`DEVICE` - corresponds to the IP adress you you device (esp8266)

`http://[device]/help` - This should give you som registers

`http://[device]/read/output` - This would for example give you some status of the output
e.g

`http://[device]/set/[group]/[adress]/[value]`- This would make you able to send commands through HTTP
`http://10.0.1.16/read/app` This is a great starter to give you info about the modbus connection being ok as this reads from the safest area of the modbus registers. Other commands might fail as controller don't know the status of the requested index e.g. if sensor is not connected or optional board is not connected.

e.g
`http://10.0.1.16/get/610/6/1` Will return read values of addresses 610-615 in holding register range.

`http://10.0.1.16/set/control/1004/2700` This will set your temperature to 27 degrees.


### Getting values by MQTT:
## Getting values by MQTT:

Here is where it all shines - the code puts out som useful MQTT topics to monitor different thing.
There is a lot of topics to be found here. I recommend using "MQTT Explorer" to se what is published.

Any MQTT-Tool (I use on my mac a tool called "MQTT Box") can be used to get the values by subscribing to :
### Listen

Here are some to listen on:

`ventilation/temp/#`- This will give the temperatures from all the sensors.

`ventilation/moist/#`- This will give the humidity from the systems humidity sensor.

`ventilation/#` - This gives the output of the system - fan speed etc. Remember the payloads are given in values not text.

### Integrate with Home Assistant.

For my integration i use a package with all my Nilan config yaml in just one file. The file can be downloaded above (config.yaml).

After a restart of Home Assistant you will get alot of new sensors. These can be integrated in Home Assistant in different ways. I use the integrated Lovelace UI to make my UI. You can see below, how it can look like:)

![HA_GUI](https://github.com/jascdk/Nilan_Homeassistant/blob/master/Home%20Assistant/HA_GUI.png)

### Making External displays, that shows you the Nilan Data:

I have tried to make some LCD´s using some 4x16 rows displays together with an ESP32 running ESP-Home www.esphome.io .

If you wanna try it out you can use my provided .yaml code for ESP-Home above:)

### SPECIAL THANKS for contribution to this project goes to: @anderskvist https://github.com/anderskvist :)



### Write back

Here are all commands you are able to send back for controlling it. I recommend sending the commands as retained messages to make sure that any faults or reboot of the controller does not affect the outcome. Retained messages are cleared once the command is accepted.

| Command | Input |Description |
| --- |---| ---|
|`ventilation/cmd/ventset`| 0-4 | Set ventilation speed |
|`ventilation/cmd/modeset`| 0-4 |Actual operation mode.0=Off, 1=Heat, 2=Cool, 3=Auto, 4=Service |
|`ventilation/cmd/runset`| 0-1 | User on / off select (equal to ON/OFF keys) |
|`ventilation/cmd/tempset`| 500-2500 | Set temperature to celsius * 100 |
|`ventilation/cmd/programset`| 0 - 4 | Start week program index |
|`ventilation/cmd/update`| 1 | Gateway has OTA active always but can be hard to reach if sometime. This puts gateway into OTA update mode for 60 seconds. |
|`ventilation/cmd/reboot`| 1 | Reboots gateway |
|`ventilation/cmd/version`| 1 | Reports compiled date back |


# Installation
Should run on most ESP8266 boards like: wemos D1 mini or nodeMCU.

## Config
Edit configuration.h file to your liking including settings for wifi and mqtt broker.

## Upload to hardware
I recommend using platform IO https://platformio.org/ inside Visual Studio Code as dependencies will be downloaded automatic in most cases due to the `platformio.ini` file.

## Make electrical connection
You can use both a hardware interface or a software one. In theory they both should give the same result but I tent to use the hardware one in production setup and the software one during debugging to allow debug messages via serial port.

Connect Tx of ESP to Rx on RS485 board. And Rx of ESP to Tx of RS485 board.

RS485 I used: [MAX3485 Module TTL To RS485 Module MCU](https://www.aliexpress.com/item/32828100565.html)

![RS485-board.JPG](images/RS485-board.JPG)

This is my setup with the Nilan HMI still connected and working fine:

![connection.JPG](images/connection.JPG)

Binary file added images/RS485-board.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/connection.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nilan-plug.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nilan-terminals.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/nodemcu.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/overview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
46 changes: 46 additions & 0 deletions lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.

The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").

For example, see a structure of the following two libraries `Foo` and `Bar`:

|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c

and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
...
}

```

PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
31 changes: 0 additions & 31 deletions nilan_code/configuration.h

This file was deleted.

Loading