Giter VIP home page Giter VIP logo

can2mqtt's Introduction

can2mqtt

A Linux or Windows service to forward CAN frames to MQTT messages

Latest Updates

This software was just updated. The main and breaking changes are:

  • Running on .NET 6.0 instead of Dotnet Core 2.2
  • Using SOCKETCAND instead of CANLOGSERVER
  • MQTT Topics changed
  • Supporting MQTT Sends
  • Supporting authentication on MQTT broker
  • Moved config to json file instead of parameters

HowTo

Note: This whole readme assumes the following environment:

  • You are running and Ubuntu based Linux distribution on a Raspberry Pi (Tested with Raspberry Pi OS and openHABian)
  • You are using the user "Pi" (if you have something else, just replace the username wherever stated)
  • You are using a fresh installation of the OS
  • You are using a USBtin device to connect to the CAN Bus (others might work but are not tested by me)
  • In thoery (and also during development I did this), socketcand and canutils can run the Raspberry Pi while can2mqtt is running on a another device in the network. That way you can also use a Raspberry Pi Zero (1st Gen) for socketcand and can-utils while running can2mqtt on another system that supports the Dotnet Framework (requires ARMv7 or later architecture).

Installation and Setup

Install .NET 6.0 Runtime

Note, the packagelink may be differnt if you are not using a OS based on ubuntu 21.04 or 21.10. Check this page for other releases: https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu This are the links from https://dotnet.microsoft.com/en-us/download/dotnet/6.0 for the differente Processor architectures for Linux: ARM32: https://download.visualstudio.microsoft.com/download/pr/f8e1ab66-58f7-4ebb-a9bb-9decfa03501f/88e1fb49af6f75dc54c23383162409c5/dotnet-runtime-6.0.4-linux-arm.tar.gz ARM64: https://download.visualstudio.microsoft.com/download/pr/3641affa-8bb0-486f-93d9-68adff4f4af7/1e3df9fb86cba7299b9e575233975734/dotnet-runtime-6.0.4-linux-arm64.tar.gz x64: https://download.visualstudio.microsoft.com/download/pr/5b08d331-15ac-4a53-82a5-522fa45b1b99/65ae300dd160ae0b88b91dd78834ce3e/dotnet-runtime-6.0.4-linux-x64.tar.gz Use the link you need for your installation in the command below. Below I will uses ARM32.

wget https://download.visualstudio.microsoft.com/download/pr/f8e1ab66-58f7-4ebb-a9bb-9decfa03501f/88e1fb49af6f75dc54c23383162409c5/dotnet-runtime-6.0.4-linux-arm.tar.gz -O ~/dotnet6.0.4.tar.gz
sudo tar -xvf dotnet6.0.4.tar.gz -C /opt/dotnet/
sudo ln -s /opt/dotnet/dotnet /usr/local/bin

Check the setup by run "dotnet --info". It should return the installed version and some other details.

can-utils installation and setup

Install can-utils

sudo apt-get install git
sudo mkdir /opt
cd /opt
git clone https://github.com/linux-can/can-utils.git
cd can-utils
make

Setup the CAN Bus connection

Assuming your device has the ID ttyACM0:

sudo /opt/can-utils/slcan_attach -f -s1 -b 11 -o /dev/ttyACM0
sudo /opt/can-utils/slcand ttyACM0 slcan0
sudo ifconfig slcan0 up

To add this to autostart and setup the adapter on every reboot, run 'sudo nano /etc/rc.local' Paste the three lines above at the end before the "EXIT 0".

socketcand installation and setup

Install socketcand

sudo apt-get install git autoconf
cd ~
git clone https://github.com/linux-can/socketcand.git
cd socketcand
./autogen.sh
./configure
make
make install
sudo mv ~/socketcand /opt

Start socketcand

This is only required to test and debug or if you like to take care of socketcand on your own. You need to replace eth0 if your network interface is called different than eth0.

 /opt/socketcand/socketcand -i slcan0 -l eth0 -v

Setup socketcand as daemon

Execute 'sudo nano /etc/systemd/system/socketcand.service', replace the network interface name if it is not eth0, replace the user with a username the daemon will use to run and paste the following:

[Unit]
Description=socketcand
After=network.target

[Service]
ExecStart=/opt/socketcand/socketcand -i slcan0 -l eth0 -v
WorkingDirectory=/opt/socketcand/
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

Finally run the following commands:

sudo systemctl enable socketcand
sudo systemctl start socketcand

MQTT Broker

You need an MQTT Broker, that is handling the MQTT traffic. You need to define the MQTT Broker IP in the can2mqtt config file later. If you don't have any MQTT broker, Mosquitto is a common MQTT Broker. Please check out on yourself how to install and configure it.

can2mqtt

Download can2mqtt

cd ~
wget https://github.com/Hunv/can2mqtt/releases/download/v4/can2mqtt_v4.zip.zip -O can2mqtt.zip
sudo unzip can2mqtt.zip -d /opt/can2mqtt

Start can2mqtt:

Optional: This is only required to test and debug or if you like to take care of can2mqtt on your own by running can2mqtt interactivly. You can also configure a daemon to do this automatically (see below).

dotnet /opt/can2mqtt/can2mqtt.dll

Setup can2mqtt as daemon

Execute 'sudo nano /etc/systemd/system/can2mqtt.service', replace the user with a username the daemon will use to run and paste the following:

[Unit]
Description=can2mqtt
After=network.target

[Service]
ExecStart=dotnet /opt/can2mqtt/can2mqtt.dll
WorkingDirectory=/opt/can2mqtt/
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

Configure config.json:

First copy the sample config.json file: 'sudo cp /opt/can2mqtt/config-sample.json /opt/can2mqtt/config.json' Edit the config.json with your favorite editor (i.e. nano): 'sudo nano /opt/can2mqtt/config.json'

{
  "CanServer": "192.168.0.10",      < This is the System where socketcand is running on
  "CanServerPort": 29536,           < This is the port socketcand is using (29536 is default)
  "CanForwardWrite": true,          < This defines if can2mqtt will handle CAN bus packages, that have the "write" flag
  "CanForwardRead": true,           < This defines if can2mqtt will handle CAN bus packages, that have the "read" flag
  "CanForwardResponse": true,       < This defines if can2mqtt will handle CAN bus packages, that have the "response" flag
  "CanReceiveBufferSize": 48,       < The buffer size of receiving commands. 48 is default.
  "CanSenderId":"6A2",              < The ID can2mqtt will use at the CAN bus in case of writing to the CAN bus
  "CanInterfaceName":"slcan0",      < The Interface name to use for the CAN bus connection

  "MqttServer": "192.168.0.10",     < This is the IP of the MQTT Broker
  "MqttClientId": "Can2Mqtt",       < This is the ID the MQTT Client will use when register at MQTT Broker
  "MqttTopic": "Heating",           < This is the first path item of the MQTT topic path can2mqtt will use for send/receive information
  "MqttTranslator": "StiebelEltron",< This is the translator used to translate the CAN bus data to values and send it via MQTT
  "MqttUser": "",                   < This is the user that is required to register at the MQTT broker. Leave empty for none.
  "MqttPassword": "",               < This is the password that is required to register at the MQTT broker. Leave empty for none.
  "MqttAcceptSet": false,           < This is a setting, that defines if can2mqtt will send write-commands to the CAN bus. For safety reasons the default setting is set to false.  
  
  "NoUnits": true,                  < This defines if sending MQTT messages will contain the unit defined in the translator config or not (i.e. "25°C" or just "25")  
  "Language": "en"                  < This defines the language, that will be used. Currently available languages are "en" (English) and "de" (German).
}

Finally run the following commands to start the daemon:

sudo systemctl enable can2mqtt
sudo systemctl start can2mqtt

MQTT Data format

can2mqtt sends the data in the topics, that are defined in the config of the translator. In case of the Stiebel Eltron translator it is the 'StiebelEltron.json'. There will be a prefix-topic in case there are other instances of can2mqtt or other MQTT applications. This one is configured in the config.json at the setting 'MqttTopic'. An example MQTT message may look like this: Topic: heating/outside/temperature/measured Value: 21°C

If you like to set data, add a /set at the end of the topic. An example MQTT message to can2mqtt to set the desired room temperature of the primary heat cycle to 23°C: Topic: heating/room/hc1/temperature/day/set Value: 23 (Important: Without the unit!)

If you need to request a send from the CAN bus, you can add a /read at the end of the topic. An example MQTT message to can2mqtt to request the value of the desired room temperature of the primary heat cycle: Topic: heating/room/hc1/temperature/day/read

Troubleshooting

Issue: The connection is reconnecting over and over again multiple times within seconds until the application crashes

Reason: Do you have a second MQTT client registered on the MQTT Broker with the same client ID?

can2mqtt's People

Contributors

hunv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

can2mqtt's Issues

Feature request: Send untranslated can package to topic /heating/<index>

Hi,

Is there a way for you to send the data in all forms you can think of if it is not in the translate table?
For instance:
When I send index 0111 you return:
/heating/0111
-> value in raw
-> value in dec
-> value in hex
-> value in bit
-> value in little endian
-> value in bool

That would be great to determine which index is what and complete/increment the translation table. (I already added some, which I found by trial and error: 0x01D4 => Source (Quelle) temperature

Because the Elster table does not match my heat pump. (A lot does, but also a lot not)

Simple question

Hello,

Nice work.

I just have a question and i cannot find the answer on the Internet, even if I can feel the answer.

I'm not used to CAN bus. I am more used to Modbus and SNMP where "nodes" can speak in a "poll-answer" schema, or even a "send to" schema. How does it work with the Heat Pump ? Does the heat pump send the data automatically on a regular basis or does it answer to a request initiated by the arduino/raspberry ?

Than you

client tried to access unauthorized bus.

Hi,

i really like this project as well. I have tested it already in version 2 and 3.1.
In Version 3.1 I got it to a point where is sends mqtt topics to the broker, but unfortunately just once and then it stopped sending updates. Now 1 year later i thought let's give i a new try and found the latest version changed to socketcan.
I have installed it on a new rasperry os setup.
I am using a canHAT on my Pi 4 so no slcan tty can be bind. My can0 is running and candump shows me the traffic of my THZ304.

the setting for the can interface i did like this:

sudo ip link set can0 type can bitrate 20000
sudo ifconfig can0 up

now i came to a stop when can2mqtt wants to opening the interface:

can2mqtt messages:

CONNECTED TO SOCKETCAND 192.168.77.59 ON PORT 29536
Handshake successful. Opening CAN interface...
Disconnected from canServer 192.168.77.59 Port 29536

socketcan messages:

Using network interface 'eth0'
Listen adress is 192.168.77.59
Broadcast adress is 192.168.77.255
creating broadcast thread...
binding socket to 192.168.77.59:29536
client connected
client tried to access unauthorized bus.
Closing client connection.

Any thoughts how I can get it up and running

can2mqtt stops after some readings

Hi,

I setup your can2mqtt on a Raspberry Pi 4B with a current Raspberry Pi OS Lite.

Linux raspberrypi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux

I followed your intructions to install the can2mqtt and it starts to transmitt the received CAN frames to my local MQTT broker (127.0.0.1), where I can receive the MQTT messages.

/usr/local/bin/dotnet /home/pi/can2mqtt_core/can2mqtt_core.dll --Daemon:MqttServer="127.0.0.1" --Daemon:MqttTranslator="StiebelEltron"
info: can2mqtt_core.DaemonService[0]
      Starting: Can2Mqtt
Application started. Press Ctrl+C to shut down.
Hosting environment: Production
Content root path: /home/pi/can2mqtt_core/
CONNECTED TO MQTT BROKER 127.0.0.1 using ClientId Can2Mqtt
CONNECTED TO CANLOGSERVER 127.0.0.1 ON PORT 28700
Received CAN Frame: (1616494454.434776) can0 180#2200FA4F4600AE
Sending MQTT Message: 180#2200FA4F4600AE and Topic Can2Mqtt
Received CAN Frame: (1616494454.558405) can0 100#3100FA4F410000
Received CAN Frame: (1616494454.564273) can0 180#2200FA4F410154
Sending MQTT Message: 180#2200FA4F410154 and Topic Can2Mqtt
Received CAN Frame: (1616494454.687213) can0 100#3100FA4F430000
Received CAN Frame: (1616494454.693692) can0 180#2200FA4F43014C
Sending MQTT Message: 180#2200FA4F43014C and Topic Can2Mqtt
Received CAN Frame: (1616494455.799755) can0 500#E100FAFE070000
Received CAN Frame: (1616494455.806185) can0 700#A200FAFE070000
Sending MQTT Message: 700#A200FAFE070000 and Topic Can2Mqtt

Unfortunately, after successfully starting the application, it stops after some readings and does not continue to produce any output. I have not seen more then 15 Received CAN Frame messages in total throughout multiple tries. The applications seems to remain in some "idle" state without crashing or something similar. A parallel running candump can0 continue to show messages though.

Different to your setup from the Readme, I use the PiCan2 shield, but I would not expect errors from that?!

Please advise me with any instructions which can help to debug this issue.

public class ConvertCent seems to round

Hi,
using the Translation for the Gradient of HC1 ("MqttTopic": "/heatcircle/hc1/gradient",)
Value of "30" is translated to "0".
Running translation with Default delivers "30" which is ok for me as a temp. workaround.

Can I somehow change the used can device name?

Hey, thank you for your great work!

I already setup socket can and everything else.
I have trouble using can2mqtt because my can device is not named slcan0, but can0. This is because I do not have a serial can bus device, but a real one.

Socketcan delivers the following after I start can2mqtt.dll:

pi@heatpump:~/socketcand $ sudo /opt/socketcand/socketcand -i can0 -l wlan0 -v
Verbose output activated

Using network interface 'wlan0'
Listen adress is 192.168.8.161
Netmask is 255.255.255.0
Broadcast adress is 192.168.8.255
creating broadcast thread...
binding socket to 192.168.8.161:29536
client connected
client tried to access unauthorized bus.
Closing client connection.
client connected
client tried to access unauthorized bus.
Closing client connection.
client connected
client tried to access unauthorized bus.

can2mqtt.dll output:

CONNECTED TO MQTT BROKER 192.168.8.138 using ClientId Can2MqttStiebelEltron
CONNECTED TO SOCKETCAND 192.168.8.161 ON PORT 29536
Handshake successful. Opening CAN interface...
Disconnected from canServer 192.168.8.161 Port 29536
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /opt/can2mqtt
CONNECTED TO SOCKETCAND 192.168.8.161 ON PORT 29536
Handshake successful. Opening CAN interface...
Disconnected from canServer 192.168.8.161 Port 29536
CONNECTED TO SOCKETCAND 192.168.8.161 ON PORT 29536
Handshake successful. Opening CAN interface...
Disconnected from canServer 192.168.8.161 Port 29536
CONNECTED TO SOCKETCAND 192.168.8.161 ON PORT 29536
Handshake successful. Opening CAN interface...
Disconnected from canServer 192.168.8.161 Port 29536
CONNECTED TO SOCKETCAND 192.168.8.161 ON PORT 29536

System.NullReferenceException when send /read or /set

I do always get a NullReferenceException when trying to read a value.
I've tested version 4.1 - 4.3

CONNECTION TO MQTT BROKER 192.168.1.123 established using ClientId Can2Mqtt
CONNECTED TO SOCKETCAND 192.168.1.124 ON PORT 29536
Handshake successful. Opening CAN interface...
Opening connection to slcan0 successful. Changing socketcand mode to raw...
Change to rawmode successful
Received MQTT READ Message; Topic = heating/room/hc1/temperature/day/read
Already connected to SocketCanD.
Failed to send a read via CAN bus. Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at can2mqtt.Can2Mqtt.ReadCan(String topic, String canServer, Int32 canPort) in C:\Dev\can2mqtt\can2mqtt_core\can2mqtt_core\can2mqtt.cs:line 277

Converter mismatch Flow Rate

Hi,
line 199 in StiebelEltron.json translator file delivers value in l/min if converter Dec is selected instead of Default

Typo "Humidtiy" in topic "Humidity"

Hi,
VERY GREAT Tool, and special Thanks to all contributions!

Please find this hint, that there is a typo in humidity related topics on mqtt:

Can be fixed in lines 6958, 7030 and 10241 in translation file StiebelEltron.json

Waveshare RS485 CAN HAT

Hi,

I have no /dev/can0 , only a can0 Interface. So I can't setup a sllcan0?

The 'candump -tz can0' is running.

BG

Kontaktaufnahme

Hi Hunv,

ich habe deine Beiträge hier und im Haustechnik Forum gelesen.
Ich selber habe eine LWZ 504 über einen USBtin mit dem Raspberry Pi verbunden.
Das Programm läuft super, wenn auch die Installation nicht reibungslos gelang (Anleitung nicht schlecht https://nocloud.info/en/attach-stiebel-eltron-lwz-504-using-usbtin-and-can-bus/ -> hat aber einige Fehler drin)

Nun empfange ich auch die ersten MQTT Einträge und habe ein paar Fragen bzw. Anregungen zur Verbesserung.

  1. Kann man irgendwo die Zeit der Abfrage für die Temperaturwerte welche alle 10 Sekunden eintreffen (wie "flow/temperature/measured") auf 60 Sekunden erhöhen?
    Außerdem nutze ich OpenHAB und da werden die Temperaturen momentan nur als Ganzzahl erkannt. Das liegt daran, dass OpenHAB ein Punkt als Trennung haben möchte. Dein Programm aber ein Komma sendet. Kann man das irgendwo einstellen?

  2. Die Zuordnung der CAN-BUS Telegramme zu den MQTT Einträgen sind nicht stimmig. Hierzu habe ich eine List angefertigt, welche ich gern einspielen würde. Weiß aber nicht wo ich das machen kann, da mit einer kompilierten *.dll gearbeitet wird.

Hier meine Liste von der LWZ 504:
Info -> Laufzeiten
180#D221FA05A415EA 15EA = 5610 [h] Laufzeit Verdichter Heizen
180#D221FA05A50000 0000 = 0 [h] Laufzeit Verdichter Kühlen (kann nicht zu 100% bestätigt werden, da 05A7 ebenfalls 0 ist)
180#D221FA05A601DB 01DB = 475 [h] Laufzeit Verdichter Warmwasser
180#D221FA05A70001 0001 = 1 [h] Elektrisch NE WW
180#D221FA05A80000 0000 = 0 [h] Elektrisch NE Heizen (kann nicht zu 100% bestätigt werden, da 05A7 ebenfalls 0 ist)

Info -> Wärmemenge
180#D221FA092E03DF 03DF = 991 [ Wh] Wärmemenge Heizen Tag
180#D221FA092F0021 0021 = 33 [kWh] Wärmemenge Heizen Tag
180#D221FA093002FE 02FE = 766 [ Wh] Wärmemenge Heizen Summe
180#D221FA09310014 0014 = 20 [kWh] Wärmemenge Heizen Summe
180#D221FA092A004A 004A = 74 [ Wh] Wärmemenge Warmwasser Tag
180#D221FA092B0002 0002 = 2 [kWh] Wärmemenge Warmwasser Tag
180#D221FA092C0212 0212 = 530 [ Wh] Wärmemenge Warmwasser Summe
180#D221FA092D0002 0002 = 2 [kWh] Wärmemenge Warmwasser Summe
180#D221FA09280000 0000 = 0 [ Wh] Wärmemenge NE Heizen Summe
180#D221FA09290000 0000 = 0 [kWh] Wärmemenge NE Heizen Summe
180#D221FA09240006 0006 = 6 [ Wh] Wärmemenge Warmwasser Summe
180#D221FA09250000 0000 = 0 [kWh] Wärmemenge Warmwasser Summe
180#D221FA03AE02F1 02F1 = 753 [ Wh] Wärmemenge Wärmerückgewinnung Tag
180#D221FA03AF0012 0012 = 18 [kWh] Wärmemenge Wärmerückgewinnung Tag Übersetzt in -> heating/recoverydaywh = 18
180#D221FA03B001C4 01C4 = 452 [kWh] Wärmemenge Wärmerückgewinnung Summe Übersetzt in -> heating/recoverydaykwh 452
180#D221FA03B10000 0000 = 0 [MWh] Wärmemenge Wärmerückgewinnung Summe Übersetzt in -> heating/heatrecoverysumkwh 0
180#D221FA06400000 0000 = 0 [ Wh] Wärmemenge Solar Heizung Tag
180#D221FA06410000 0000 = 0 [kWh] Wärmemenge Solar Heizung Tag
180#D221FA06420000 0000 = 0 [ Wh] Wärmemenge Solar Heizung Summe (könnte auch kWh sein)
180#D221FA06430000 0000 = 0 [kWh] Wärmemenge Solar Heizung Summe (könnte auch MWh sein)
180#D221FA06440000 0000 = 0 [ Wh] Wärmemenge Solar Warmwasser Tag
180#D221FA06450000 0000 = 0 [kWh] Wärmemenge Solar Warmwasser Tag
180#D221FA06460000 0000 = 0 [ Wh] Wärmemenge Solar Warmwasser Summe (könnte auch kWh sein)
180#D221FA06470000 0000 = 0 [kWh] Wärmemenge Solar Warmwasser Summe (könnte auch MWh sein)
180#D221FA06480000 0000 = 0 [ Wh] Wärmemenge Kühlen Summe (könnte auch kWh sein)
180#D221FA06490000 0000 = 0 [kWh] Wärmemenge Kühlen Summe (könnte auch kWh sein)

Wie gesagt, ich würde gerne meinen Beitrag zu diesem schönen Programm leisten.

VG
Peter (Xtremdiver)

Combined value topic

Add a combined value topic, that will return the result of a combination of two topics.

i.e. if the total power consumption should be returned, you will get the absolute value in one topic instead of two. No manual logic needs to be done afterwards anymore.

How to obtain all info

Hi!

Let me first start with saying that you did a great job!
Really impressive and very well documented and great tutorial.

I all got it working like a charm using the USBtin and a pi!
But... I'm not getting al the info:
Schermafbeelding 2022-09-05 om 19 30 30

I tried to 'send' topics with the MQTT Explorer, but that didn't do anything.

I do have a different system: WPF 07 Cool
So I guess some of the ID's are different.

My question is, how did you determine the ID's.
Can you get me started, so I can change the JSON file to match my ID's?

Thanks in advance!

communication breakdowns

Hi all,

I think this topic is not really an issue with that software, but I would like to know if some of you have the same issue?
From time to time the communication breaks down and does not reestablish. I then notice that no mqtt messages are received at my mqtt broker. I am not 100% sure if the reason is relly just the mqtt side I could also imagine that the connection between socket can and can2mqtt is interupted and doe not recover.

So I had the idea if it is possible to configure in the can2mqtt module either a status topic what frequently send a "alive" message to the broker and / set a "last will" statement for the mqtt user which could inform my homeassitant to perform a reboot with my raspberry.

What are your thoughts on that?

CAN Bus liefert nurWarmwasserwerte, und weitere Infos erst (!), wenn es am Display eingesehen wird

Hallo zusammen,

wie der Titel schon andeutet, funktioniert can2mqtt tadellos und liefert auch Werte. Kontinuierlich empfange ich über MQTT die Warmwassertemperatur und den Volumenstrom. Zusätzliche Daten, wie die Vorlauf-/Rücklauftemperatur oder der Druck im Heizkreis, werden jedoch nur übertragen, wenn ich manuell durch das Informationsmenü der Wärmepumpe navigiere. In diesem Fall aktualisieren sich die Werte direkt auf den neuesten Stand. Zum Monitoring in Grafana ist das leider unbrauchbar.

Im Einsatz ist eine Tecalor THZ eco 5.5 die Baugleich ist mit der Stiebel LWZ 5.

Irgendjemand eine Idee?

Enchancements to Stiebel Eltron translation (specifically WPF 10E)

I did some modifications to can2mqtt_core codebase. I don't have any github repo, so I'll list those modifications to here. Sorry about manual work.

StiebelEltron.json
Here's my Stiebel Eltron translator:
StiebelEltron-mikkopalo-json.txt

ElsterIndex.cs
add following lines to the Converter function:

                    case "abt":
                        return new ConvertAbt();

ValueConverter.cs
I don't know what to put to the ConvertValueBack function.. So now there's something and dotnet doesn't nag about this function. :)

public class ConvertAbt : IValueConverter
    {
        public string ConvertValue(string hexData)
        {
            switch (hexData)
            {
                case "0000": return "{\"compressor\": \"OFF\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"OFF\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"OFF\", \"poweroff_enable\": \"OFF\", \"source_pump\": \"OFF\"}";
                case "0100": return "{\"compressor\": \"OFF\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"OFF\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"OFF\", \"poweroff_enable\": \"ON\", \"source_pump\": \"OFF\"}";
                case "0200": return "{\"compressor\": \"OFF\", \"dhc1\": \"ON\", \"dhc2\": \"OFF\", \"buffer_pump\": \"OFF\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"OFF\", \"poweroff_enable\": \"OFF\", \"source_pump\": \"OFF\"}";
                case "0400": return "{\"compressor\": \"OFF\", \"dhc1\": \"OFF\", \"dhc2\": \"ON\", \"buffer_pump\": \"OFF\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"OFF\", \"poweroff_enable\": \"OFF\", \"source_pump\": \"OFF\"}";
                case "0800": return "{\"compressor\": \"OFF\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"OFF\", \"poweroff_enable\": \"OFF\", \"source_pump\": \"OFF\"}";
                case "2000": return "{\"compressor\": \"OFF\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"OFF\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"OFF\"}";
                case "2100": return "{\"compressor\": \"ON\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"OFF\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"OFF\"}";
                case "2800": return "{\"compressor\": \"OFF\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}";
                case "2900": return "{\"compressor\": \"ON\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}";
                case "2A00": return "{\"compressor\": \"OFF\", \"dhc1\": \"ON\", \"dhc2\": \"OFF\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"OFF\"}";
                case "2B00": return "{\"compressor\": \"ON\", \"dhc1\": \"ON\", \"dhc2\": \"OFF\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}";
                case "2C00": return "{\"compressor\": \"OFF\", \"dhc1\": \"OFF\", \"dhc2\": \"ON\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"OFF\"}";
                case "2E00": return "{\"compressor\": \"OFF\", \"dhc1\": \"ON\", \"dhc2\": \"ON\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"OFF\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"OFF\"}";
                case "3900": return "{\"compressor\": \"ON\", \"dhc1\": \"OFF\", \"dhc2\": \"OFF\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"ON\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}";
                case "3B00": return "{\"compressor\": \"ON\", \"dhc1\": \"ON\", \"dhc2\": \"OFF\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"ON\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}";
                case "3D00": return "{\"compressor\": \"ON\", \"dhc1\": \"OFF\", \"dhc2\": \"ON\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"ON\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}";
                case "3E00": return "{\"compressor\": \"OFF\", \"dhc1\": \"ON\", \"dhc2\": \"ON\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"ON\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}";
                case "3F00": return "{\"compressor\": \"ON\", \"dhc1\": \"ON\", \"dhc2\": \"ON\", \"buffer_pump\": \"ON\", \"dhw_valve\": \"ON\", \"heat_circ_pump\": \"ON\", \"poweroff_enable\": \"ON\", \"source_pump\": \"ON\"}"; 
                default: return "Unbekannt";
            }
        }
        public string ConvertValueBack(string value)
        {
            switch (value)
            {
                case "fish":
                    return "0000";
                default: return "";
            }
        }
    }

Just my 0.02 eurocents. :)

Services started but not working

Hi,

If the pi is just started, it works, but after a while it stops. Not sure what is happening.
I restarted the services a couple of times, but they don't seem to work anymore, while they say they do.

Here is my output of both services and a command which implies that there is no device:

justin@warmtepomp-pi:/opt/can/can-utils $ sudo systemctl status socketcand.service
● socketcand.service - socketcand
Loaded: loaded (/etc/systemd/system/socketcand.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-09-06 19:49:35 BST; 2min 17s ago
Main PID: 2357 (socketcand)
Tasks: 3 (limit: 4164)
CPU: 109ms
CGroup: /system.slice/socketcand.service
├─2357 /opt/socketcand/socketcand -i slcan0 -l wlan0 -v
└─2542 /opt/socketcand/socketcand -i slcan0 -l wlan0 -v

Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: Verbose output activated
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: Using network interface 'wlan0'
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: Listen adress is 192.168.55.253
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: Broadcast adress is 192.168.55.255
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: creating broadcast thread...
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: binding socket to 192.168.55.253:29536
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: client connected
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: connecting BCM socket...
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: state changed to 2
Sep 06 19:51:48 warmtepomp-pi socketcand[2538]: Closing client connection.

justin@warmtepomp-pi:/opt/can/can-utils $ sudo systemctl status can2mqtt.service
● can2mqtt.service - can2mqtt
Loaded: loaded (/etc/systemd/system/can2mqtt.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-09-06 19:51:16 BST; 45s ago
Main PID: 2477 (dotnet)
Tasks: 21 (limit: 4164)
CPU: 3.753s
CGroup: /system.slice/can2mqtt.service
└─2477 dotnet /opt/can2mqtt/can2mqtt.dll

Sep 06 19:51:53 warmtepomp-pi dotnet[2477]: CONNECTED TO SOCKETCAND 192.168.55.253 ON PORT 29536
Sep 06 19:51:53 warmtepomp-pi dotnet[2477]: Handshake successful. Opening CAN interface...
Sep 06 19:51:53 warmtepomp-pi dotnet[2477]: Opening connection to slcan0 successful. Changing socketcand mode to raw...
Sep 06 19:51:53 warmtepomp-pi dotnet[2477]: Change to rawmode successful
Sep 06 19:51:53 warmtepomp-pi dotnet[2477]: Disconnected from canServer 192.168.55.253 Port 29536
Sep 06 19:51:58 warmtepomp-pi dotnet[2477]: CONNECTED TO SOCKETCAND 192.168.55.253 ON PORT 29536
Sep 06 19:51:58 warmtepomp-pi dotnet[2477]: Handshake successful. Opening CAN interface...
Sep 06 19:51:58 warmtepomp-pi dotnet[2477]: Opening connection to slcan0 successful. Changing socketcand mode to raw...
Sep 06 19:51:58 warmtepomp-pi dotnet[2477]: Change to rawmode successful
Sep 06 19:51:58 warmtepomp-pi dotnet[2477]: Disconnected from canServer 192.168.55.253 Port 29536

justin@warmtepomp-pi:/opt/can/can-utils $ ./cansend slcan0 6A2#3100FA05970000
if_nametoindex: No such device

/set wird von meiner Heizung nicht übernommen

@Hunv, danke für das tolle Projekt. Bin darauf gestossen als ich nach einer Verstellung der Warmwassertemperatur für meine StiebelEltron WPL-16-S-trend, bei PV Strom Überschuss gesucht habe.
Ich kann nun Werte mitloggen die von der Anlage im CanBus gepusht werden.

Kann aber noch nicht mit /set den Wert verstellen.
Wenn ich die "Warmwasser Soll Tag" auf 46°C ändern will, sende ich...

Received MQTT SET Message; Topic = heating/dwh/temperature/day/set and Payload = 46
Already connected to SocketCanD.
CAN Frame is: 6A0#3000FA001301CC
Sending CAN Frame: < send 6A0 7 30 0 FA 0 13 1 CC >
Sending CAN Verify Frame: < send 6A0 7 31 0 FA 0 13 1 CC >
Received CAN Frame: < frame 180 1674228810.251238 D220FA001301F5 >
Sending MQTT Message: 50.1 and Topic heating/dwh/temperature/day

der Wert ändert sich aber nicht sondern bleibt bei 50.1°C stehen.

Ich hatte vorher in der in der config.json per default "CanSenderId": "69F" stehen, hatte die auf 6A0 geändert das bracht aber nichts.

So sieht meine config.json aus.

pi@can2mqtt:/opt/can2mqtt $ more config.json 
{
  "CanServer": "192.168.77.105",
  "CanServerPort": 29536,
  "CanForwardWrite": true,
  "CanForwardRead": true,
  "CanForwardResponse": true,
  "CanReceiveBufferSize": 48,
  "CanSenderId": "6A0",

  "MqttServer": "192.168.77.10",
  "MqttClientId": "Can2Mqtt_dev",
  "MqttTopic": "heating",
  "MqttTranslator": "StiebelEltron",
  "MqttUser": "",
  "MqttPassword": "",
  "MqttAcceptSet": true,

  "NoUnits": true,
  "Language": "en"
}

Hat jemand eine Idee? Danke.

Problem while installing can2mqtt

First at all:
I do have an PICAN 2! an Raspberry Pi 3.

When i try to set up the connection between my Tecalor WPM (3) which should be the same as Stiebel Eltron WPM 3, i can see that many data can be read via:

pi@raspberrypi:~ $ sudo systemctl status socketcand
● socketcand.service - socketcand
Loaded: loaded (/etc/systemd/system/socketcand.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-07-02 13:30:41 BST; 6h ago
Main PID: 507 (socketcand)
Tasks: 2 (limit: 1595)
CPU: 17ms
CGroup: /system.slice/socketcand.service
├─507 /opt/socketcand/socketcand -i slcan0 -l eth0 -v
└─640 /opt/socketcand/socketcand -i slcan0 -l eth0 -v

Jul 02 13:30:41 raspberrypi systemd[1]: Started socketcand.

pi@raspberrypi:~ $ candump can0
can0 480 [7] A0 00 2C 00 00 00 00
can0 180 [7] A0 79 0C 00 B9 00 00
can0 480 [7] A0 00 2C 00 00 00 00
.....
....
..
.

So i think, that data from the can bus can read via the pican2 and the sofware.

Problems beginn, when i try so send data via mqtt to my openhab system:

pi@raspberrypi:~ $ sudo systemctl status can2mqtt
● can2mqtt.service - can2mqtt
Loaded: loaded (/etc/systemd/system/can2mqtt.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-07-02 13:30:47 BST; 6h ago
Main PID: 566 (dotnet)
Tasks: 20 (limit: 1595)
CPU: 3.186s
CGroup: /system.slice/can2mqtt.service
└─566 dotnet /opt/can2mqtt/can2mqtt.dll

Jul 02 13:30:54 raspberrypi dotnet[566]: CONNECTED TO SOCKETCAND 192.168.178.251 ON PORT 29536
Jul 02 13:30:54 raspberrypi dotnet[566]: Handshake successful. Opening CAN interface...
Jul 02 13:30:54 raspberrypi dotnet[566]: Opening connection to slcan0 successful. Changing socketcand mode to raw...
Jul 02 13:30:54 raspberrypi dotnet[566]: Change to rawmode successful
Jul 02 13:30:54 raspberrypi dotnet[566]: Error while reading CanBus Server. System.FormatException: Input string was not in a correct format.
Jul 02 13:30:54 raspberrypi dotnet[566]: at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
Jul 02 13:30:54 raspberrypi dotnet[566]: at System.Convert.ToInt64(String value, IFormatProvider provider)
Jul 02 13:30:54 raspberrypi dotnet[566]: at can2mqtt.CanFrame.set_RawFrame(String value) in D:\Productions#git\can2mqtt\can2mqtt_core\can2mqtt_core\CanFrame.>
Jul 02 13:30:54 raspberrypi dotnet[566]: at can2mqtt.Can2Mqtt.TcpCanBusListener(String canServer, Int32 canPort) in D:\Productions#git\can2mqtt\can2mqtt_core>
Jul 02 13:30:54 raspberrypi dotnet[566]: Already connected to SocketCanD.

pi@raspberrypi:~ $ dotnet /opt/can2mqtt/can2mqtt.dll
Cannot find config.json. Copy and rename the config-sample.json and adjust your settings in that config file.
DISCONNECTED FROM MQTT BROKER
DISCONNECTED FROM MQTT BROKER
RECONNECTING TO MQTT BROKER FAILED
DISCONNECTED FROM MQTT BROKER
RECONNECTING TO MQTT BROKER FAILED
DISCONNECTED FROM MQTT BROKER
RECONNECTING TO MQTT BROKER FAILED
RECONNECTING TO MQTT BROKER FAILED
Unhandled exception. MQTTnet.Exceptions.MqttCommunicationException: Value cannot be null. (Parameter 'host')
---> System.ArgumentNullException: Value cannot be null. (Parameter 'host')
at MQTTnet.Implementations.CrossPlatformSocket.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at MQTTnet.Implementations.MqttTcpChannel.ConnectAsync(CancellationToken cancellationToken)
at MQTTnet.Internal.MqttTaskTimeout.WaitAsync(Func`2 action, TimeSpan timeout, CancellationToken cancellationToken)
at MQTTnet.Adapter.MqttChannelAdapter.ConnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MQTTnet.Adapter.MqttChannelAdapter.WrapAndThrowException(Exception exception)
at MQTTnet.Adapter.MqttChannelAdapter.ConnectAsync(TimeSpan timeout, CancellationToken cancellationToken)
at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken)
at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken)
at can2mqtt.Can2Mqtt.StartAsync(CancellationToken stoppingToken) in D:\Productions#git\can2mqtt\can2mqtt_core\can2mqtt_core\can2mqtt.cs:line 150
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Program.

$(String[] args) in D:\Productions#git\can2mqtt\can2mqtt_core\can2mqtt_core\Program.cs:line 12
at Program.(String[] args)
Aborted

Has someone an idea which could be wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.