pimatic-radioheaddeprecated

RadioHead for Pimatic

Usage no npm install needed!

<script type="module">
  import pimaticRadiohead from 'https://cdn.skypack.dev/pimatic-radiohead';
</script>

README

build status npm version

pimatic-radiohead

pimatic-radiohead is a pimatic plugin that integrates RadioHead into pimatic.

With pimatic-radiohead you are able to include pimatic into your RadioHead network using a serial interface. You may also use a small microprocessor (e.g. an Arduino nano) as a serial-radio-gateway to include some radio hardware.

Build you own bus system based on pimatic, RS485 and radio devices!

RadioHead is a open source Packet Radio library for embedded microprocessors. It provides addressed, reliable, retransmitted, acknowledged variable length messages.

pimatic-radiohead uses the radiohead-serial Node.js module.

German version of this readme: README-de.md

Attention: Since v2.0.0 this plugin requires at least Node.js v8.9!

Features

  • Receive messages/commands from other nodes in you local RadioHead network.
  • Send messages/commands to other nodes in you local RadioHead network.
  • Devices to show and process messages received from other nodes.
  • Devices to send messages to other nodes.
  • Rules are supported for triggering actions and sending messages including variables.
  • Device attributes give you some statistics about sent and received messages.
  • Multiple RadioHead networks are supported using different serial interfaces.

Device configuration localized in:

  • en - English
  • de - German

Devices

All device configuration can be done using the pimatic frontend.

A detailed description of all config options is available in the file device-config-schema.coffee.

RadioHeadSerialPort

This is a special device, which provides the interface to the serial hardware.

It is needed for all other devices.

By default only messages addressed to this node or the broadcast address are handled. You may activate the promiscuous mode to handle messages with any to address.

RadioHeadSerialPort

RadioHeadContactSensor

A ContactSensor based on received messages.

You need to define some data bytes, which have to match a received messages for the closed and opened action. An automatic reset is also possible, if the sending device only emits one action.

RadioHeadContactSensor

RadioHeadPresenceSensor

A PresenceSensor based on received messages.

You need to define some data bytes, which have to match a received messages for the present and absent action. An automatic reset is also possible, if the sending device only emits one action.

RadioHeadPresenceSensor

RadioHeadSwitch

A Switch which sends configurable messages if turned on or off.

RadioHeadSwitch

RadioHeadShutter

A ShutterController which sends configurable messages if moved up, moved down or stopped. An automatic stop is also possible, if you wish to stop after a specific time.

RadioHeadShutter

RadioHeadButtonsDevice

A ButtonsDevice to provide some buttons. One button can send and/or receive messages.

You may use this device to send a message if the user clicks a button in the frontend.

You may also use this device to handle some buttons from a remote control.

RadioHeadButtonsDevice

RadioHeadButtonsDevice

RadioHeadButtonsDevice

RadioHeadWeatherStation

A Sensor which can receive and display various weather information.

You are able to define multiple data messages to extract the values. Each value can be preprocessed by an expression to manipulate the received value.

Values which consists of more than one byte can be in Little-Endian (LE) or Big-Endian (BE) format.

Supported data types in a message are: 32bit Float LE, 64bit Double LE, 8bit Integer, 8bit Unsigned Integer, 16bit Integer LE, 16bit Unsigned Integer LE, 32bit Integer LE, 32bit Unsigned Integer LE, 4bit Float BE, 8bit Double BE, 16bit Integer BE, 16bit Unsigned Integer BE, 32bit Integer BE, 32bit Unsigned Integer BE

Use the following indicators to mark the positions of the values in the data messages:

  • t - temperature
  • h - humidity
  • p - air presure
  • r - rain
  • ws - wind speed
  • wd - wind direction
  • wg - wind gust
  • b - battery status
  • lb - low battery

RadioHeadWeatherStation

RadioHeadWeatherStation

RadioHeadCustomSensor

A Sensor which can receive and display various numeric and boolean data.

You can define multiple custom numeric and boolean sensor values and you are able to define multiple data messages to extract the values. Each numeric value can be preprocessed by an expression to manipulate the received value.

Values which consists of more than one byte can be in Little-Endian (LE) or Big-Endian (BE) format.

Supported data types in a message are: 32bit Float LE, 64bit Double LE, 8bit Integer, 8bit Unsigned Integer, 16bit Integer LE, 16bit Unsigned Integer LE, 32bit Integer LE, 32bit Unsigned Integer LE, 4bit Float BE, 8bit Double BE, 16bit Integer BE, 16bit Unsigned Integer BE, 32bit Integer BE, 32bit Unsigned Integer BE

Use you own or the following predefined indicators to mark the positions of the values in the data messages:

  • b - battery status

RadioHeadCustomSensor

RadioHeadCustomSensor

RadioHeadCustomSensor

RadioHeadCustomSensor

Rule syntax and examples

Predicates (when ...)

You may use the following conditionals to trigger a rule:

radiohead [received] "<dataBytes>" from <senderAddress> [to <recipientAddress>] using <device>
  • received - Optional word for better readability.
  • dataBytes - The received data bytes in hex notation, separated by spaces. You may use a * as wildcard to accept any byte at this position.
  • senderAddress - The address of the sending node in the RadioHead network in hex notation. You may use 0xFF to accept all senders.
  • recipientAddress - Optional. The address of the receiving node in the RadioHead network in hex notation. If omitted, the own address of the device will be used. Useful for broadcasts or if the RadioHeadSerialPort device is used in promiscuous mode.
  • device - ID or name of the RadioHeadSerialPort device which is used.

Examples

radiohead received "0x01 0x02 0xAB" from 0x05 using rh-serial-1

radiohead received "0x01 0x02 0xAB" from 0x05 to 0x01 using rh-serial-1

radiohead "0x63 0x72 0x79 0x43 0x6F 0x64 0x65 * 0x64 0x65" from 0xFF using rh-serial-1

rule-when

Actions (then ...)

You may use the following action in a rule:

[send] radiohead "<dataBytes>" to <recipientAddress> using <device>
  • send - Optional word for better readability.
  • dataBytes - The data bytes in hex notation to send, separated by spaces. You may also use variables as described below.
  • recipientAddress - The address of the receiving node in the RadioHead network in hex notation. Use 0xFF for broadcast messages.
  • device - ID or name of the RadioHeadSerialPort device which is used.

Examples

send radiohead "0x01 0x02 0xAB" to 0x05 using rh-serial-1

radiohead "0x63 0x72 0x79 0x43 0x6F 0x64 0x65" to 0xFF using rh-serial-1

send radiohead "0x55 $my_var d$my_double_var i$my_int_var b$my_boolean_var" to 0x42 using rh-serial-1

rule-then

rule-when-then

Variables in Actions

You can include pimatic variables in the data bytes as well as static byte values.

There are some modifiers to define the datatype of the transmitted variable content. A modifier is a single letter, which is prefixed to the variable name.

  • Without any modifier a variable will be sent as one byte, representing the 8-bit unsigned integer value of that variable.
  • i - 32-bit integer
  • I - 16-bit unsigned integer
  • d - 64-bit double
  • f - 32-bit float
  • b - boolean (false=0x00, true=0x01)

All variables will be sent using little-endian format.

Example

"0x01 $my_var d$my_temperature" will sent 10 bytes: One byte with the fixed value 0x01, one byte representing the 8-bit value of $my_var and 8 bytes representing the temperature saved as double in $my_temperature.

Attributes

The following attributes are provided by each RadioHeadSerialPort device as pimatic variables:

  • sentOkCount - The count of successfully sent messages since the last start.
  • sentErrorCount - The count of faulty sent messages since the last start.
  • receivedCount - The count of received messages since the last start.
  • retransmissionsCount - The count of retransmitted messages since the last start. High values indecat problems (e.g. bus collisions or unreachable devices).

Debug

You can enable the debug mode in the plugin config.

In debug mode you will find all received RadioHead messages in the log and some other additional information, e.g. about matched data for the devices.

License

Licensed under GPL Version 2

Copyright (c) 2017-2020 Peter Müller peter@crycode.de (https://crycode.de/)

Some parts of the RadioHeadWeatherStation devices are inspired by pimatic-homeduino.