Search

Lazy Man Joe's Ramblings

Node-RED flow for Geyser management using Sonoff switches and Home Assistant

We have 2 geysers (for other parts in the world it’s called water heaters :-)) in our house and to save some energy (& money), we want to manage when these geysers are switched on.

Typically a geyser will run 24/7 and keep the water heated, even when nobody is home.

So the idea is to put the geysers on a time-schedule for when we’re normally at home, so we only heat the water when we’re going to use it.

To put this in motion, there are a couple of things we need to do:

  1. Connect the Sonoff switch to the geysers [using a Sonoff Dual, so 1 Sonoff & 2 relays]
  2. Configure the Switches in Home Assistant
  3. Configure a flow to ensure the geysers are on at specific times during the week & weekend

Connecting the Sonoff Switch to the Geysers

Geysers tend to draw a lot of power when the element is on and the Sonoff Dual switch is only rated for 16A/10A – which is fine for normal use, but won’t cut it for geyser use.

We need to implement another solution:
– the solution is using a 230V/30Amp relay.

30A-Relay

This will allow us to use the Sonoff switch, but the main load will pass through the relay instead of theย  Sonoff switch.

Now we have to connect the geysers in the distribution box to the Sonoff switch [some rewiring required here]

DB-board

That’s it !

[P.S. I already configured the Sonoff on the network, so this wiring was all I needed to do]

Connecting the Sonoff Switch to Home Assistant

To make Home Assistant aware of the switch, we need to add some configuration info into the configuration.yaml file.

I added the following lines: (I moved all the switch configs to a separate switches.yaml file)

Configuration.yaml (add these line)
# Put switch config in separate file
switch: !include switches.yaml

Now in the switches.yaml add the config info for the geyser switches:
– platform: mqtt
name: “Bedroom Geyser”
command_topic: “cmnd/Sonoff1/power1”
state_topic: “stat/Sonoff1/POWER1”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Upstairs Geyser”
command_topic: “cmnd/Sonoff1/power2”
state_topic: “stat/Sonoff1/POWER2”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true

As you can see, it uses mqtt (Mosquitto Broker) to communicate with the switches (command_topic & state_topic)

So now these switches will show up in Home Assistant (after a restart of HASS)

HA-Switches

OK now we move to the FUN stuff !

Configure the Node-RED Flow in Home Assistant

We decided that for our purposes the following schedule makes sense:
– Weekdays the geysers need to be on in the morning & the evening
– Weekends we will run the geysers most of the day (as we may shower at any time & tend to be around more)

The flow looks like this:

GeyserFlow

I split the flows into 2 separate ones for possible future changes where the geysers will be on different schedules.

Also, the basic flow is my 1st attempt [put it in place today] – so we may tweak it over time ๐Ÿ™‚

Over-ride:

Sometimes we may actually select to switch the geysers on when we want – which we can always do from the Home Assistant front-end.

I’m also thinking of adding a flag to state when we have guests staying over, and then disabling the schedule, etc. [future project :-)]

Another thing I also need to do is have a physical over-ride button connected to the Sonoff switch (there are pins available for this) – this will allow me to manually switch the geysers on in the event the Sonoff loses connectivity to the wifi.

Well, this was an eventful couple of days !

Now deciding on to the next bit of automation ! ๐Ÿ™‚

 

Have fun !

Advertisements

Sonoff Wifi Switches – Flashing it with Tasmota Over-The-Air (OTA)

A friend of mine recently introduced me to the Sonoff switches – affordable, easy to use AND RE-programmable ! [Thanks Cliff ;-)]

I got the Sonoff Dual switch, which allows you to switch 2 separate appliances/devices from 1 Wifi switch.

dual2

Anyways, to get going I decided to flash it with the Sonoff-Tasmota firmware (as I wanted to be able to pull it into my Home Assistant setup easily)

The instructions on the Tasmota-Sonoff Wiki is fairly easy to follow and although they suggest you use a wiredย 3.3V FTDI USB-to-Serial Converter/Programmer (or a Raspberry Pi) – I also noticed you can use Wifi to update the firmware Over-The-Air !

The tool for that is called SonOTA. [Please note not all Sonoff switches may support this – so make sure you have a supported Sonoff Firmware version BEFORE you try to flash with SonOTA)

There are a couple of ways to get SonOTA working:

  1. Using the Windows pre-built .EXE (you can find it here)
    1. I used this as a 1st pass for the 1st Sonoff Dual switch I flashed with the firmware
    2. This is a quick & dirty way – but it CAN work & there’s nothing wrong with this ๐Ÿ™‚
  2. Installing the SonOTA software on your machine & customising it as you need (this involves installing Python 3, etc. on your local machine)
    1. Here you can customise some of the setting beforehand
    2. I left all vanilla & it still worked fine ๐Ÿ™‚

Once you have SonOTA on your machine, you can run it and follow the instructions on-screen.

The process involves:

  1. Running SonOTA (./sonota.py)
  2. Confirming the configuration of you local machine to ensure you have all the required bits in place
  3. Putting your Sonoff in Access Point (AP) mode [holding the button in for more than 7 seconds] and then connecting to the ITEAD-* wifi network
  4. Installing a small base firmware uploader
  5. The Sonoff will then connect to you local machine to get the actual firmware installed
  6. Just be patient and things will happen ๐Ÿ™‚
  7. Once installed, you will go into “FinalStage” mode
    1. Here you connect to the Sonoff [wifi now called FinalStage] and configure it to be able to connect to your wifi network
    2. Once configured, it will reboot and join your wifi
  8. Then you have to check your router /DHCP server to make sure your Sonoff’s IP address gets reserved (to make sure it doesn’t change on power loss / reboot)

Upgrading your Sonoff to the latest Tasmota Firmware

The SonOTA tool flashes a version of Tasmota which may be outdated (you CAN update the config manually, but why worry ? :-))

So once you have your Sonoff on your wifi network, you can connect directly to it and select the “Firmware Upgrade” option

Tasmota-Upgrade

Get the latest Sonoff-Tasmota firmware release here [select the .bin version which is applicable to you, normally just sonoff.bin]

Upload it and wait for the Sonoff to reboot with the latest version.

Great – Now you’re SET !

Next steps:

  1. Connect your Sonoff to the device / devices you want to control & get going !
  2. Integrate into Home Assitant

Have fun !

Home-Assistant.io and Hassio – The best and easiest Home Automation tools to get going !

I’ve played with some home automation stuff on my Raspberry Pi in the past, but setting up the stuff was always a bit involved and I would loose interest somewhere down the line. This meant I’ve always had good intentions, but never really implemented anything (all the work was “proof-of-concept” stuff :-))

Well that has changed in the last couple of days ! ๐Ÿ™‚

HomeAssistant-Dashboard

Home-Assistant.io, Hass.io, Sonoff switches (running Tasmota Firmware) and Node-Redย changed ALL of that !

What do you need:

  1. Somewhere to run Home Assistant (I used a Raspberry Pi 3)
  2. Install Home Assistant
    1. They have an easy to follow install guide
  3. Once you have Home Assistance installed, you configure Hass.io to help you manage additions, etc. on Home Assistant
    1. A couple of add-ons I use:
    2. Hassio-Dashboard
      1. Configurator (makes it easy to edit Home Assistant configuration yaml files)
      2. Samba share (to connect to the Raspberry Pi and be able to edit files if the front-end breaks)
      3. SSH Server (if you’re more used to using ssh to connect to your Pi)
      4. TasmoAdmin (used because I make use of Sonoff switches running Tasmota firmware)
      5. Mosquitto Broker (used to communicate with your switches)
      6. Node-Red (Visual Environment for putting “flows” together)
  4. You install all of these add-ons via the Hass.io Add-On Store
  5. THEN you need some switches
    1. I’m using the Sonoff switches as they’re easy to use and not too expensive
    2. I installed the Tasmota Firmware on them
  6. Adding your Sonoffs to Home Assistant involves some configuration editing (will cover that in a separate post), but once you have it working – it works like a charm !

Have fun !

 

How to get telnet onto MacOS High Sierra

Sometimes you just want to drop into a terminal window and test some “stuff”.

If you are running MacOS High Sierra (10.13), you may notice that telnet is not available as part of a standard install anymore ๐Ÿ˜ฆ

Well, the Homebrew guys have come to the rescue and provide an option to install the “missing packages on macOS”.

Head over to brew.sh for more info.

Basically you have to install Homebrew and then after that you can install other packages.

In terminal, paste the following:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

wait for the install to finish (it will download and install the Xcode command-line tools, as well as configure homebrew.)

Once you’ve done this you can install packages like telnet, etc.

For telnet use this command:

brew install telnet

Have fun !

Adding Porn, Fake News and Gambling blocking to PiHole

I’ve been using the RaspberryPi PiHole ad-blocking installation (see my post) quite successfully in our home environment and am very happy with it.

Lately I’ve also looked at adding additional content blocking to the solution to block other content like:

  • Porn
  • Gambling
  • Fake News

I found the following resources for hosts which you can add to your Block Lists in PiHole.

Steven Black’s Lists (multiple – select which one makes sense for you)

Chad Mayfields’ List (post) and actual list

To configure:

  1. Open your PiHole Dashboard and login
  2. Go to Settings -> Block Lists
  3. Add the following to your current lists (PiHole already has ad-blocking lists)
    1. https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
    2. https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts
    3. https://raw.githubusercontent.com/chadmayfield/pihole-blocklists/master/lists/pi_blocklist_porn_top1m.list
  4. Save and Update

The PiHole installation will pull all the hosts into its configuration and ensure the sites are blocked on a DNS level.

Sample screen of my current configuration

PiHoleBlockLists

You may find however that some sites are classified as “porn” (i.e. Maxim.com, etc.) but this is probably due to some potential content on there which is deemed “close” to porn ๐Ÿ™‚

A small price to pay for better piece of mind – although the lists will not block all content (new sites pop up every day), it will help with the majority of the content.

You always have the option to add your own Blacklist sites and I recommend you review the PiHole DNS queries on a regular basis to see any potential additional items to add.

Have fun !

Raspberry Pi, Homebridge, Apple & Siri

About a year ago I was playing with my Raspberry Pi, connecting it via HomeBridge to my Apple TV & iPhone.

HomeBridge links of interest:

This was just a proof of concept and I never posted about it on my blog ๐Ÿ˜ฆ

I am planning on doing some work on this again (soon) – doing some automation at home for my garden, etc.

In the meantime – some of the videos from a year ago:

https://www.youtube.com/watch?v=JFq824Yditw

https://www.youtube.com/watch?v=z9tFEF8FzdI

https://www.youtube.com/watch?v=BZEXJil-KD8

https://www.youtube.com/watch?v=NrMXOTM2-wM

https://www.youtube.com/watch?v=ncvaOB08CGE

 

Struggling with Locales on your Raspberry Pi ? Here’s a fix !

I tend to tinker with my Raspberry Pi every now & then, but keep on running into a Locale issue.

Even using the sudo raspi-config utility doesn’t seem to fix things ๐Ÿ˜ฆ [btw – I’m setting the locale to en_ZA.UTF-8 as I’m in South Africa :-)]

I found the following way seems to work best as it FORCES the locale info ๐Ÿ™‚

Use the following:

sudo nano /etc/default/locale

In the editor, make the following changes:

LANG=en_ZA.UTF-8
LC_ALL=en_ZA.UTF-8
LANGUAGE=en_ZA.UTF-8

Save and reboot !

This fixed the issue for me.

Have fun !

Deleting your Facebook account #DELETEFACEBOOK

Used this article as a guide on how to delete my Facebook account permanently.

 

https://mashable.com/2018/03/19/how-to-delete-facebook-account/#EKUnvbrLdPqp

 

Quite a big step for me – although I’ve not been using FB actively the last year ๐Ÿ™‚

Tunnelblick – free software for OpenVPN on OS X and macOS

I installed PiVPN on one of my Raspberry Pi’s at home yesterday to set up my own VPN server at home. (blog post)

As PiVPN makes use of OpenVPN on the Raspberry Pi, I’ve been looking for an easy to use ย OpenVPN client for my Mac.

Tunnelblick is a free open source OpenVPN VPN client which fits the bill ๐Ÿ™‚

Have a look here to get it –ย Tunnelblick

Setup is easy:

  • ย Install Tunnelblick on your Mac
  • Download the .ovpn configuration file from your VPN server (PiVPN in my case)
  • Double-click on the file.
  • Tunnelblick will automatically open the configuration and you’re ready to connect ๐Ÿ™‚

Easy !

Have fun !

Blog at WordPress.com.

Up ↑