Automation HAT - Node-Red nodes


#1

Hi, I was looking for node-red nodes which I can use to control the automation hat.
Unfortunately these don’t exist yet at this point in time, so I started with the development of these. I am willing to contribute these to the community if I can get some technical questions answered.

Currently I have written a node to control relay one on the automation hat.
In the background a python script is launched which is using automationhat.relay.one.on() to switch on the relay.
When the python script is closed, the relay reverts to the off position. All good here. But.
When I launch my python script again, the relay starts in the on position, as if it has remembered the previous state.
Is there any way to prevent this, as a predictive startup state should be desirable.


#2

I was able to resolve the problem.
The problem lies within your init library, where you initialise the gpio pins for the relays.
There seems to be a missing parameter on line 188:

GPIO.setup(self.pin, GPIO.OUT, initial=0)

the initial=0 parameter was missing which determines the startup state of the pins which controls the relays.

https://github.com/pimoroni/automation-hat/blob/master/library/automationhat/init.py


#3

This is great news- good to have someone who knows the Node/Node-RED side of things chiming in. I just couldn’t keep up with Node itself, much less maintain ports of all our libraries :(

I’m a little surprised the initial state of the pin survives the setup process, but it seems obvious in retrospect.

I’ll raise an issue against the library to remind me to fix this.


#4

Hi,
I have been developing a leak detection project to monitor for a possible hot water tank
leak with email alarm capability. The project consists of a Zero W running Node-Red
with the an Automation pHat analog input connected to a Honeywell Leak Detection cable.

Since no Automation pHat node is available, originally I used python code and SSH to
manually monitor the analog value of the cable. I decided to use an Node-Red input node
as a timer to trigger an Exec node that executed the python file every 5 seconds.
The return value was passed on as a msg.payload object to a couple of Execute nodes for
limit evaluations and creation of an email message before calling an Email node to send
the message.

The problem I encountered was the message returned from a variation of the analog.py
example, always contained the text "“Automation pHAT detected…”. This message
interfered with the next evaluation step in the process.

The easiest method to resolve this problem was to open the appropriate init.py file
for the python version being used and commenting out line 250. This eliminated
the message that was creating the problem and the entire code now works.

Changing the standard init.py source to make this message an option might be
worth considering.


#5

This is actually something I have in the works- as part of preventing import-time side effects and to address problems like this. Automation HAT has been delayed somewhat since it’s a little trickier, but it’s in progress: https://github.com/pimoroni/automation-hat/pull/13