GithubHelp home page GithubHelp logo

crycode-de / iobroker.canbus Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 6.0 7.36 MB

ioBroker CAN Bus integration

License: Other

JavaScript 10.19% HTML 0.27% TypeScript 89.22% CSS 0.33%
iobroker iobroker-adapter can-bus

iobroker.canbus's Introduction

ioBroker.canbus

Logo

NPM version Downloads Number of Installations (latest) Number of Installations (stable) Translation status

NPM

Tests: Test and Release

CAN bus adapter for ioBroker

This adapter connects ioBroker to a Controller Area Network (CAN bus).

This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers. For more details and for information how to disable the error reporting see Sentry-Plugin Documentation! Sentry reporting is used starting with js-controller 3.0.

Features

  • Receive and send raw messages using standard frames and extended frames
  • Each message may be configured for receiving and/or sending data
  • Ability to automatically add objects for seen CAN messages which are not already configured
  • Configure parsers for each message to read/write data from/to the raw message buffer
    • Numeric types
    • Booleans including bitmask support
    • Strings in different character encodings
    • Custom scripts to read/write from/to the buffer of raw data
  • Advanced import/export feature
    • Import message configurations to extends your existing configuration
    • Import predefined "well known" configurations from GitHub within the admin interface
    • Export and import your message configurations as json or csv files
  • Optional support for fixed data lengths (DLC)
  • Optional support for the RTR flag
  • Optional raw states containing raw CAN message objects
  • Optional automatically set a certain value in a given interval for each parser (usefull for polling data)

Requirements

  • Linux operating system (because of the used socketcan library)
  • CAN Hardware which is supported by the kernel and creates an interface like can0
  • Some knowledge about the messages send on you CAN bus

Parsers

Using parsers you are able to read data from or write data to the CAN message buffer.

There are predefined parsers for the following data types.
Additionally you may write you own scripts to read/write values with a custom parser.

Numeric types in big-endian and little-endian reperesentation

  • Signed and unsigned 8, 16 and 32 bit integer
  • 32 bit float
  • 64 bit double

Boolean

  • 1 byte including bitmask support

String

  • 1 to 8 byte length
  • Encoding: ascii, base64, hex, latin1, utf8, utf16le

Custom

For a custom parser you have to provide you own read and write script.
These scripts should be pure javascript and will run in a sandbox.

In the scripts you are able to use the following features:

  • Most of Node.js build in functions
  • async/await
  • Adapter log functions log.warn('something'), log.info('something'), log.debug('something')
  • getStateAsync('id') and getObjectAsync('id') where id is the full ID of the state/object
  • An object sharedData which is shared between all custom scripts of an adapter instance

Errors in the scripts will be logged by the adapter.

In both scripts the variables buffer and value are predefined.
buffer always contains the current CAN message content as a Node.js Buffer.

The sharedData object is empty by default and may be used to share some data between multiple calls of a single custom parser or even between multiple custom parsers.

Custom read script

In a read script you have to read the value from the buffer variable.

At the beginning of the custom read script, buffer will be the received/current CAN message data (like in the .json state). value will be undefined and should be set by the script.

The content of the value variable at the end of the custom read script will be used as new value for the state.
If value is undefined, it will be ignored. Using this you are able to filter messages in the custom read script by data parts.

Example for a custom read script

Check the first three bytes in the received buffer to match fixed values.
If matched, read an 16 bit signed integer value from the buffer bytes 3 and 4 and divide it by 10.

if (buffer[0] === 0xC2 && buffer[1] === 0x10 && buffer[2] === 0x0F) {
  value = buffer.readInt16BE(3) / 10;
}

Cause of value is only set when the first three bytes matched, all other data will be ignored and won't set a new value to the state.

Custom write script

In a write script you have to modify (or replace) the buffer variable.

At the beginning of the custom write script, buffer will be the current CAN message data (like in the .json state). value is set to the value of the state which should be written into the buffer.

The content of the buffer variable at the end of the custom write script will be used as new data for the CAN message.

Example for a custom write script

Prepare a new buffer with fixed values.
Write the state value into the buffer as a signed 16 bit integer, beginning at the fifth byte in the buffer.

buffer = Buffer.from([0x30, 0x00, 0xFA, 0x06, 0x7E, 0x00, 0x00]);
buffer.writeInt16BE(value, 5);

The new buffer will then be set as the .json state.
If the autosend option is enabled for the message, the message will be automatically send.

Usage in scripts

You can handle/modify the <messageId>.json or <messageId>.<parserId> states in your scripts.

Additionally you may use the raw.received and raw.send states, if you have them enabled in the adapter config.
They hold the stringified JSON data of the message data and can be used to handle each received or send message independent from the configured messages. By writing JSON data to the raw.send state you are able to send CAN messages containing any data you like.

Raw message object example

{
  "id": 42,
  "ext": false,
  "data": [0, 13, 37, 255],
  "rtr": false
}

ext and rtr are optional and default to false.

Changelog

1.3.1 (2022-04-19)

  • (crycode-de) Fixed autoSetValue defaults for parsers
  • (crycode-de) Fixed sentry admin integration
  • (crycode-de) Updated dependencies

1.3.0 (2022-02-07)

  • (crycode-de) Added sharedData object in custom parsers

1.2.3 (2021-10-17)

  • (crycode-de) Added missing autoSet... parser options to csv export/import
  • (crycode-de) Fixed TypeError: Method Promise.prototype.then called on incompatible receiver [object Object] triggered by a bug in an old vm2 version
  • (crycode-de) Updated dependencies

1.2.2 (2021-08-22)

  • (crycode-de) Fixed text colors in dark theme of admin 5
  • (crycode-de) Updated dependencies

1.2.1 (2021-06-22)

  • (crycode-de) Added option to automatically set a certain value in a given interval for each parser
  • (crycode-de) Added checks for duplicate parser IDs
  • (VeSler) Russian translation updates
  • (crycode-de) Use inline sourcemaps for the adapter build files to make remote debugging work
  • (crycode-de) Updated dependencies

1.1.4 (2021-04-30)

  • (crycode-de) Added license information to import of well-known configurations
  • (crycode-de) Fixed "Parser returned wrong data type undefined" log message
  • (crycode-de) Updated dependencies

1.1.3 (2021-04-12)

  • (crycode-de) Added definition of possible state values in admin
  • (crycode-de) Added selection of the state role for each parser in admin
  • (crycode-de) Fixed display bug of floating action buttons in admin
  • (crycode-de) Export uses defaults if some config parts are not defined (e.g. if the config is from an older version)
  • (crycode-de) Fixed wrong validation if a message/parser was deleted

1.1.2 (2021-04-06)

  • (crycode-de) Added copy/paste function for message and parser configurations in admin

1.1.1 (2021-04-02)

  • (crycode-de) Import bugfixes
  • (crycode-de) Prevent wrong log warning if a parser returned undefined
  • (crycode-de) Added react errorboundary for better clientside error handling

1.1.0 (2021-04-01)

  • (crycode-de) Added import/export feature for messages in json or csv format
  • (crycode-de) Added import of well known configurations from GitHub
  • (crycode-de) Fixed config import in admin
  • (crycode-de) Added ioBroker state data type option for custom parsers

1.0.2 (2021-03-26)

  • (crycode-de) Fixed issue where missing state prevented custom parser write
  • (DutchmanNL) Dutch translation updates
  • (UncleSamSwiss) French translation updates
  • (VeSler) Russian translation updates

1.0.1 (2021-03-12)

  • (crycode-de) Use a queue to process parser and send state changes in the correct order
  • (crycode-de) Fixed some spelling issues
  • (crycode-de) Updated dependencies

1.0.0 (2021-02-23)

  • (crycode-de) Sort messages in admin
  • (VeSler) Russian admin translations
  • (crycode-de) Updated dependencies

Older changelog is in CHANGELOG_OLD.md

License

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)

Copyright (c) 2020-2022 Peter Müller [email protected] (https://crycode.de/)

iobroker.canbus's People

Contributors

crycode-de avatar dependabot[bot] avatar dutchmannl avatar iobrokertranslator avatar johnnybyzhang avatar ldittmar81 avatar maag-da avatar palmmaniac avatar sbormann avatar schmakus avatar shortcircuit0815 avatar sneak-l8 avatar unclesamswiss avatar vesler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

iobroker.canbus's Issues

Fehler nach neustem Nodejs update

hi ich habe heute mal mein System auf den neusten Stand gebracht also auch nodejs, nach der Anleitung von Dutchman.
Jetzt bekomme ich diese Fehlermeldung:
adapter "canbus" seems to be installed for a different version of Node.js. Trying to rebuild it... 1 attempt

Weißt du woran das liegt?

Node.js: v18.15.0
NPM: v9.5.0
iobroker Version 6.3.5

autoSetValue missing sometimes

When autoSetInterval is enabled for a parser without changing the default autoSetValue, the autoSetValue will not be set in the config which leads to log messages like undefined is not a valid state value for id "canbus.0.680.fac0f6".

The adapter should check for undefined autoSetValue and use the default internally.

See https://forum.iobroker.net/post/777649

Feature Enhancement config "Modus SG abfragen (fa0694)

Hi,

I am missing the set option for fa0694.
"Modus SG abfragen (fa0694)" works as expected. But I am missing the set option for the "Modus SG setzen (xxxx)".

Can this please be enhanced in the config file. If I could deliver any necessary info, just let me know.

Thanks in advance
Alex

Warning at adapter install

When installing the adapter I get the following message:

"npm warn deprecated [email protected]: The library contains critical security issues and should not be used for production! The maintenance of the project has been discontinued. Consider migrating your code to isolated-vm."

Auto trigger message send on specific interval

There should be an option to automatically trigger sending of messages at a given interval which would be useful for periodic data requests.

Should be at parser level with a given parser input value.
Optionally trigger the send action after the parser completes.

Please consider fixing issues detected by repository checker

Notification from ioBroker Check and Service Bot

Dear adapter developer,

I'm the ioBroker Check and Service Bot. I'm an automated tool processing routine tasks for the ioBroker infrastructure. I have recently checked the repository for your adapter canbus for common errors and appropiate suggestions to keep this adapter up to date.

This check is based the current head revisions (master / main branch) of the adapter repository

Please see the result of the check below.

ioBroker.canbus

Downloads Number of Installations (latest) Number of Installations (stable) - Test and Release

ERRORS:

  • ❗ [E026] "{'engines': {'node'>='16'}}" is required at package.json, "{'engines':{'node'>='18'}}" is recommened
  • ❗ [E033] @iobroker/adapter-core 2.6.7 specified. 3.1.4 is required as minimum, 3.1.6 is recommended. Please update dependencies at package.json
  • ❗ [E036] @iobroker/testing 2.6.0 specified. 4.1.3 is required as minimum, 4.1.3 is recommended. Please update devDependencies at package.json
  • ❗ [E162] js-controller 2.0.0 listed as dependency but 4.0.24 is required as minimum, 5.0.19 is recommended. Please update dependency at io-package.json.

WARNINGS:

👍 No suggestions found

Please review issues reported and consider fixing them as soon as appropiate.

Errors reported by repository checker should be fixed as soon as possible. Some of them require a new release to be considered as fixed. Please note that errors reported by checker might be considered as blocking point for future updates at stable repository.

Warnings reported by repository checker should be reviewed. While some warnings can be ignored due to good reasons or a dedicated decision of the developer, most warnings should be fixed as soon as appropiate.

You may start a new check at any time by adding the following comment to this issue:

@iobroker-bot recheck

Please note that I (and the server at GitHub) have always plenty of work to do. So it may last up to 30 minutes until you see a reaction. I will drop a comment here as soon as I start processing.

Feel free to contact me (@ioBroker-Bot) if you have any questions or feel that an issue is incorrectly flagged.

And THANKS A LOT for maintaining this adapter from me and all users.
Let's work together for the best user experience.

your
ioBroker Check and Service Bot

@mcm1957 for evidence

Last update at Fri, 06 Sep 2024 07:11:40 GMT

Compatibility check to js-controller 4.0

Dear Adapter developer,

with js-controller 4.0 object definitions are now also checked that min/max in only provided for number/mixed objects and that the type of the default value matches to the object type.

If something is not correct this is logged as 'warning' or 'info' log.

Please also make sure to update to the lastest @iobroker/testing dependency 2.5.4 or to accept the PR from Apollon77 for legacy testing!

Please spent some time to verify your adapter by ideally starting with a fresh instance and do some actions and verify the log. If you see a warn or info log there from these checks please adjust the adapter and fix the relevant cases.

For questions please refer to ioBroker/ioBroker.js-controller#1749

Please close the issue after you checked it.

Thank you very much for your support to get the best experience for the growing numbers of ioBroker users!

Data type for custom parsers

If a custom parser is used, you should be able to select a data type (string, number, boolean, mixed) for the state.

The related object should have the data type set accordingly.
The return value of the custom parser read should be checked against this setting.

Please consider fixing issues detected by repository checker

Notification from ioBroker Check and Service Bot

Dear adapter developer,

I'm the ioBroker Check and Service Bot. I'm an automated tool processing routine tasks for the ioBroker infrastructure. I have recently checked the repository for your adapter canbus for common errors and appropiate suggestions to keep this adapter up to date.

This check is based the current head revisions (master / main branch) of the adapter repository

Please see the result of the check below.

ioBroker.canbus

Downloads Number of Installations (latest) Number of Installations (stable) - Test and Release

ERRORS:

  • ❗ [E026] "{'engines': {'node'>='16'}}" is required at package.json, "{'engines':{'node'>='18'}}" is recommended
  • ❗ [E033] @iobroker/adapter-core 2.6.7 specified. 3.1.4 is required as minimum, 3.1.6 is recommended. Please update dependencies at package.json
  • ❗ [E036] @iobroker/testing 2.6.0 specified. 4.1.3 is required as minimum, 4.1.3 is recommended. Please update devDependencies at package.json
  • ❗ [E157] js-controller 2.0.0 listed as dependency but 4.0.24 is required as minimum, 5.0.19 is recommended. Please update dependency at io-package.json.

WARNINGS:

👍 No suggestions found

Please review issues reported and consider fixing them as soon as appropiate.

Errors reported by repository checker should be fixed as soon as possible. Some of them require a new release to be considered as fixed. Please note that errors reported by checker might be considered as blocking point for future updates at stable repository.

Warnings reported by repository checker should be reviewed. While some warnings can be ignored due to good reasons or a dedicated decision of the developer, most warnings should be fixed as soon as appropiate.

You may start a new check or force the creation of a new issue at any time by adding the following comment to this issue:

@iobroker-bot recheck
@iobroker-bot recreate

Please note that I (and the server at GitHub) have always plenty of work to do. So it may last up to 30 minutes until you see a reaction. I will drop a comment here as soon as I start processing.

Feel free to contact me (@ioBroker-Bot) if you have any questions or feel that an issue is incorrectly flagged.

And THANKS A LOT for maintaining this adapter from me and all users.
Let's work together for the best user experience.

your
ioBroker Check and Service Bot

@mcm1957 for evidence

Last update at Fri, 20 Sep 2024 02:19:07 GMT based on commit ab68a69
ioBroker.repochecker 3.0.7

Compatibility check to js-controller 3.3 and Admin5 React UI

Dear Adapter developer,

with js-controller 3.2 and js-controller 3.3 some additional checks were added to make sure that created objects match to the specifications and also written state values match to the object definition.

If something is not correct this is logged as 'warning' or 'info' log.

Please take the time to verify your adapter by ideally starting with a fresh instance and do some actions and verify the log. If you see a warn log there from these checks please adjust the adapter and fix the relevant cases.

For questions please refer to ioBroker/ioBroker.js-controller#1301

Additionally we are preparing Admin 5 which will have a completely rewritten UI. Please install Admin 5, activate that new UI and verify that the configuration of you adapter works as expected also there.

More informations on Admin 5 can be found in Forum https://forum.iobroker.net/topic/44282/test-adapter-admin-5-0-x-alpha-der-neuen-ui

Please close the issue after you checked it.

Thank you very much for your support!

Compatibility check and testing for node.js 22

Notification from ioBroker Check and Service Bot

Dear Adapter developer,

Node.js 22 will become the official node.js LTS release October 2024 - see node-releases

So please check your adapter with Node.js 22.

Please add node.js 22 to the adapter testing matrix which is executed on commits. This check is normally controlled by workflow located at .github/workflows/test-and-release.yml. The recommended testmatrix is [18.x, 20.x, 22.x] now. It's ok to test node.js 20.x and 22.x only if there are any technical reasons (i.e. requirements caused by dependencies) to do so.

In any case please set the 'engines' clause in package.json according to the minimum node version used at testing. Please also do this if the adapter is not able to work with certain Node.js versions, so that ioBroker can prevent users from installing the adapter if not compatible. If you detect any incompatibility with node.js 22 please try to fix it and / or let us know if the problem seems to be located at core components.

Please close the issue after you checked it.

Feel free to contact me (@ioBroker-Bot) if you have any questions.

And THANKS A LOT for maintaining this adapter from me and all users.
Let's work together for the best user experience.

your
ioBroker Check and Service Bot

@mcm1957 for evidence

Note: If you added node 22 tests already, simply close this issue.

Hardware recommendation

Hi!
I´m using MCP2515 with Raspberry but messages get lost.
500kbits

I know it because i got an CAN USB Adapter for my windows pc and there i can see more messages.

can you recommend hardware for raspberry pi?

support request

Hello crycode-de,
first: congratulation and many thanks for the canbus-adapter.

As ioBroker beginner I needed long time to get it work ;-). Your example config helped a lot to integrate all "my wished functions" of StiebelEltron LWZ 403 SOL.
But now I have questions, I couldn't find the solution by myself.
I hope it is ok to create an GitHub issue ... if not, just tell me a better way...

  1. Combination of CAN-signals to one "datapoint". Is there a clever posibility to do it in the adapter ? Currently I have a "blockly-script doing the calculation"
    example of two signals:
    "WM WRG Tag Wh" -> can0 180 [7] D2 1E FA 03 AE "readInt16BE(5)"
    "WM WRG Tag kWh" -> can0 180 [7] D2 1E FA 03 AF "readInt16BE(5)"
  2. Currently I querie values by sending in intervalls. I set different intervall values to the single messages. But with lots of values it's not easy not to send in same time lots of requests. How did you do it with external scripts?

best regards & again: thanks for the really good adapter!
Tobi

Presets for well known configs

Put well known configurations in the GitHub repo and add an option to load them in admin.
The configs should be read live from GitHub to be independent from adapter updates.

Compatibility check and testing for Node.js 14 and 16

Dear Adapter develop,

Node.js 14 is now available for a year and Node.js 16 was release just some days ago and will become LTS by October 2021. We plan to update the ioBroker Node.js recommendation (currently 12.x) to 14.x later this year.

Please check your adapter with Node.js 14 especially, and ideally also directly with Node.js 16

Please add both versions to the adapter testing which is executed on commits.

If your adapter requires a certain minimum version of Node.js please set the 'engine' setting in package.json accordingly! Please also do this if the adapter is not able to work in certain Node.js versions, so that ioBroker can prevent users from installing te adapter if not compatible!

On questions please talk to us at ioBroker/ioBroker.js-controller#1138

Please close the issue after you checked it.

Thank you very much for your support!

Viessmann Vitocal 250-A

Hello, I would like to control my Vitocal 250-A with the iobroker.can-bus adapter, but no matter what I set, I only get nonsensical values. Can someone help me with what I have to set so that correct values ​​come out. There is already a Github project with an independent interface (https://github.com/abnoname/open3e.git). This should be a UDS protocol. Viessmann also provides a data point list Viessmann Datenpunktliste

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.