Hi,
As promised, here is me feedback:
My main concern was not about the board interface or the board capabilities but just about the dialog between this board and Openhab.
So, I did not play with DSscript at all. I only used the default firmware of the DS3484.
Be sure to set your board in binary mode.
Be sure to use fixed IP adress.
For the communication with OpenHAB, I use NodeRED.
It was very easy, even for a beginner.
- Install NodeRED on your OpenHABian or where you want…
- From your main OpenHABian page (http://10.0.1.150:8080/start/index), open NodeRED
- Create a new flow and add nodes like this:
3.1. Add an Inject Node with Payload [“0x34”,“0x01”]. I put a repeat interval of 5s. Topic is empty.
3.2. Add an HTTP request Node. Configure the IP and port of the DS3484. Set a timeout of 500ms.
3.3. Add 8 Function Nodes (1 by Input).
Function are the following:
D1
if ((msg.payload[1] & 1) == 1)
{ msg.payload = “D1 is ON”; }
else
{ msg.payload = “D1 is OFF”; }
var D1=flow.get(‘D1’) || 0;
if (D1 != msg.payload)
{
flow.set(‘D1’,msg.payload);
return msg;
}
D2
if ((msg.payload[1] & 2) == 2)
{ msg.payload = “D2 is ON”; }
else
{ msg.payload = “D2 is OFF”; }
var D2=flow.get(‘D2’) || 0;
if (D2 != msg.payload)
{
flow.set(‘D2’,msg.payload);
return msg;
}
D3
if ((msg.payload[1] & 4) == 4)
{ msg.payload = “D3 is ON”; }
else
{ msg.payload = “D3 is OFF”; }
var D3=flow.get(‘D3’) || 0;
if (D3 != msg.payload)
{
flow.set(‘D3’,msg.payload);
return msg;
}
etc… etc…
I used variables to store the states of Inputs and for publishing state ONLY when state change.
3.4. Add one MQTT Out Node by function. In server, select your MOSQUITTO server. In topic, set for instance DS3484/state/D2
It is done for NodeRED
- Add a new Generic MQTT thing for the DS3484 board. (I choose MQTT_DS3484)
- Create 8 channels. (one by Input)
Exemple for D1:
Type: text value
ID: D1
Name: D1
State Topic: DS3484/state/D1
- Create 8 string items and link them to your channes
Exemple for D1:
String Input_D1 “State of Input D1: [%s]” { channel=“mqtt:topic:MQTT_DS3484:D1” }
It works very well but feel free to comment. this can probably be improved.
Mike