esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
411 stars 26 forks source link

NMEA 2000 protocol support #2760

Open mgrouch opened 3 months ago

mgrouch commented 3 months ago

Describe the problem you have/What new integration you would like

Some use EspHome on boats. NMEA 2000 support would come very handy. There are existing libraries and solutions for esp32 but not with EspHome.

Here are few links

https://github.com/bareboat-necessities/bbn-nmea200-m5atom

https://github.com/ttlappalainen/NMEA2000

https://github.com/ttlappalainen/NMEA2000_esp32

https://github.com/AK-Homberger/NMEA2000-TempPressure

Please describe your use case for this integration and alternatives you've tried:

NMEA 2000 PGN sentences as HomeAssistant sensors.

Additional context

rici44 commented 3 months ago

would be great +1

nagyrobi commented 3 months ago

It appears that this is a kind of CAN-bus: https://en.wikipedia.org/wiki/NMEA_2000 CAN is supported by ESPHome. on_frame trigger and canbus.send action can be used to deal with raw data in Lambdas.

Definitely not as simple as having a dedicated component, but I think it should be already possible with CAN.

mgrouch commented 3 months ago

It appears that this is a kind of CAN-bus: https://en.wikipedia.org/wiki/NMEA_2000 CAN is supported by ESPHome. on_frame trigger and canbus.send action can be used to deal with raw data in Lambdas.

Definitely not as simple as having a dedicated component, but I think it should be already possible with CAN.

It’s not enough. Each PGN should map to a homeassistant sensor. CAN frames need to be parsed using this library

https://github.com/ttlappalainen/NMEA2000

into PGN (wind speed, tank liquid level, engine RPM, etc).

Then it could be very usable in HomeAssistant or over MQTT.

randybb commented 3 months ago

If you want to make a sensor connected to n2k or a device that will pull data from n2k then sure, it make sense. But if you are going to have HA on your boat, then you can connect it directly to the n2k bus https://smartboatinnovations.com/ / https://community.home-assistant.io/t/homeassistant-integrations-for-a-boat/378857

mgrouch commented 3 months ago

Good point. Now I realize that several use cases possible.

one creating a sensor to feed some PGN data into NMEA 2000 network with EspHome yaml. Without user needing code in C++. This doesn’t exist yet.

another use case is NMEA 2000 to HomeAssistant or MQTT gateway. Mapping all data from NMEA 2000 to separate HomeAssistant sensors. again on esp32 device without c++ coding (just yaml). So HomeAssistant would automatically recognize all data from NMEA 2000 network without need of NMEA 2000 integration you mentioned. User should be able to choose the way data is fed into HomeAssistant. WiFi, Ethernet, Bluetooth, usb serial, uart etc.

BTW Victron energy systems use NMEA 2000 heavily. So it’s not just for boats.

randybb commented 3 months ago

Victron supports multiple CAN protocols, including NMEA2000 and RV-C (like n2k, just for RV's :D). It is just an option for simpler integration. You can use the bare CAN as for other inverters/BMS (some are already supported).

With n2k support you could easily create a sensor for your boat or just a nice display for reading states (M5Tough is an ideal device for this), which could be super cool.

Anyway, the other CAN protocols would be nice too - SAE J1939 (for cars, but for some boat motors), CANopen (basically done, but not officially yet) and RV-C (for super rich people :D)

mgrouch commented 3 months ago

Victron supports multiple CAN protocols, including NMEA2000 and RV-C (like n2k, just for RV's :D). It is just an option for simpler integration. You can use the bare CAN as for other inverters/BMS (some are already supported).

With n2k support you could easily create a sensor for your boat or just a nice display for reading states (M5Tough is an ideal device for this), which could be super cool.

Anyway, the other CAN protocols would be nice too - SAE J1939 (for cars, but for some boat motors), CANopen (basically done, but not officially yet) and RV-C (for super rich people :D)

I’ve done it for m5tough (in c++) though for NMEA 0183/ Victron MQTT/ PyPilot/ SignalK.

Network part can be rewritten to use NMEA 2000 as data input instead.

Here is the code:

https://github.com/bareboat-necessities/bbn-m5stack-tough

mgrouch commented 3 months ago

BTW it’s easier to make it work with BBN Marine OS (free and opensource for pi4/5) which also includes SignalK, PyPilot, etc HomeAssistant with both integrations for NMEA 0183 and N2K from smartboatinnovations.

https://bareboat-necessities.github.io/

mgrouch commented 3 months ago

It would be nice to be able to create NMEA 2000 senders on esp32 without need for pi or HomeAssistant. And without programming in c++. Just config in .yaml for EspHome

randybb commented 3 months ago

Was reading about these Victron devices and they have it really nice integrated. Thanks to n2k it is using standard profiles (pgn) and autodiscovery/central configuration is build-in, really nice. Now we need to find somebody who is smart enough to create such component (master/slave).