This is the third in a set of posts about the home automation tutorial from linux.conf.au 2019. You should probably read part 1 and part 2 before this post.
In the end Alistair decided that my home automation shield was defective, which is the cause of the errors from the past post. So I am instead running with the prototype shield that he handed me when I started helping with the tutorial preparation. That shield has some other bugs (misalignments of holes mainly), but is functional apart from that.
I have also decided that I’m not super excited by hassos, and just want to run the orangepi with the OWFS to MQTT gateway into my existing home assistant setup if possible, so I am going to focus on getting that bare component working for now.
To that end, the gateway can be found at https://github.com/InfernoEmbedded/OWFS-MQTT-Bridge, and is a perl script named ha-daemon.pl. I needed to install some dependancies, which in my case were for armbian:
$ apt-get install perl libanyevent-perl cpanminus libdist-zilla-perl libfile-slurp-perl libdatetime-format-strptime-perl
$ dzil listdeps | cpanm --sudo
Then I needed to write a configuration file and put it at ha.toml in the same directory as the daemon. Mine looks like this:
[general]
timezone="Australia/Sydney"
discovery_prefix="homeassistant"
[1wire]
host="localhost"
port=4304
timeout=5 # seconds, will reconnect after this if no response
sensor_period=30 # seconds
switch_period=10 # seconds
debug=true
[mqtt]
host="192.168.1.6"
port=1883
Now run the gateway like this:
$ perl ha-daemon.pl
I see messages on MQTT that a temperature sensor is being published to home assistant:
homeassistant/sensor/1067C6697351FF_temperature/config {
"name": "10.67C6697351FF_temperature",
"current_temperature_topic": "temperature/10.67C6697351FF/state",
"unit_of_measurement": "°C"
}
However, I do not see temperature readings being published. Having added some debug code to OWFS-MQTT, this appears to be because no temperature is being returned from the read operation:
2019-05-27 17:28:14.833: lib/Daemon/OneWire.pm:73:Daemon::OneWire::readTemperatureDevices(): Reading temperature for device '10.67C6697351FF'
[...snip...]
2019-05-27 17:28:14.867: /usr/local/share/perl/5.24.1/AnyEvent/OWNet.pm:117:Daemon::OneWire::__ANON__(): Read data: $VAR1 = bless( {
'payload' => 0,
'size' => 0,
'version' => 0,
'offset' => 0,
'ret' => 4294967295,
'sg' => 270
}, 'AnyEvent::OWNet::Response' );
I continue to debug.