Home Automation - Smartkit

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
9,138
Working on something different for a change. Will be building a distance sensor for my water tanks, but don't want to use an ESPxx, mostly because I would like to run it off a battery and maybe add a small solar panel to charge it during the day, but theoretically it should be able to run for months on the battery if only using RFM69.

So this means, I need a RFM69 to Ethernet or Wifi bridge, using the former.

First the struggle was with the gateway :mad: Then the first sensor node :mad: and then figuring out the MySensors.org library :mad::mad::mad: (but it does make the coding 100000% less so its awesome).

The problems:

1. Ethernet works, RFM69 radio works, each separately, but not when both connected at the same time.
This one, took me 6 hours to figure out.
-> solution was to remove pin 10 from the radio shield and connect it to pin 9, and set it different in software code.

2. Using Adafruit Feather 32u4 radio (has on-board RFM69).
At first, had issues flashing it, but turns out I had to un-install ModemManager on my Ubuntu Mate PC.

3. For the life of me, couldn't get the RFM69 to initialize. Eventually found the pins are connected different than standard, but also the definitions to change this in MySensors.org library at first made no sense, having changed from pre 2.1.x to 2.1.x and I am on 2.3.1 and also some examples show differences for production vs development and not to mention 99% examples are all for pre 2.1.x.

Anyways, tested a basic on/off switch scenario. Well no switch, I just connected the wire and disconnected to see it work.

Here some photos.

Gateway node. Notice pin 10 is sticking out to the side (my hack of a work-around). And above it you will see me linking ping 10->9
From top to bottom:
1. RFM69HCW shield (apparently has a temp sensor included)
2. W5100 ethernet shield (causing the problem on pin 10 not playing nice with SPI and other modules)
3. Arduino Uno
gatgeway.jpg

The sensor node, currently with nothing connected but the wire for the areal. It has a battery charger and connected included by default and the RFM69 radio. Saves a lot of time, for some cost, but worth it to me.
sensor-node.jpg


The serial debug output on the Gateway node.
gateway-read-sending-to-mqtt.png

mqtt traffic using mostquito_sub to see that it works.
0 means closed
1 means open
Node ID is 3.
255 is the gateway id sending a 0 for something.
mqtt.png
 

rodga

Executive Member
Joined
May 9, 2007
Messages
9,615
Recording how much rain we get...?
For interest's sake really I guess. Maybe one day I'll think of a cool automation for it.
I see, was hoping you already had something cool to automate from it lol
link to the sensor?
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
37,064
AS long as you still have the non-smart backups (i.e. keys) available.

So you're running your gate motor and garage -- correct? Any door locks / magnetic locks?

My wife went for walks while she was pregnant and also appreciated that she only needed to take a phone and not a bulky set of keys. She could open the gate with just her phone (but yeah, she kept a door open somewhere).
Yeah for anything other than walking to school I have the keys in the bike and in the car still but have just realised (with my post) that I haven't used them which really tells me the automation was a success.

Have the front gate, garage and alarm. No interest in door locks as we don't even use them now with real physical keys.

Only lock that gets locked is the garage door into the house at night and the in between door to the bedrooms.

I guess those would be nice to automate for when the alarm gets armed in Stay mode, but of course I haven't prepped for that. Could probably do that with a second Sonoff SV and coding another PGM but not really that stressed about it.

With door locks in SA not being "dead bolt" setups like America it's generally more complicated than it needs to be.
 

l3ok

Member
Joined
Sep 17, 2013
Messages
25
Anyone here connected their alarm to HA or have built a custom alarm with sonoff components and HA?
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
37,064
Anyone here connected their alarm to HA or have built a custom alarm with sonoff components and HA?
“Connected” is a relative term.

I’ve taken a dumb alarm and kept it pretty dumb with a wireless on/off ability and status monitoring.
 

calypso

Expert Member
Joined
Feb 10, 2009
Messages
1,442
Problem is at that price even before the shipping costs and import duties you are already at what it would cost you to just do it locally.
There is nothing available locally at anywhere near that price. My Smart Blinds will also attract the same duties and lower shipping.

Actually, just looking at Amazon's currently pricing on IKEA blinds, should be about +50% for shipping and duties. Still reasonable.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
37,064
There is nothing available locally at anywhere near that price. My Smart Blinds will also attract the same duties and lower shipping.

Actually, just looking at Amazon's currently pricing on IKEA blinds, should be about +50% for shipping and duties. Still reasonable.
Can't call a link off hand now but when I looked into it a few months ago a roller blind for my needs was about a grand and then automating it would cost me another grand which is why I didn't scratch any further into it as I needed three blinds for one room.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
37,064
How pray tell have you done this sir?
When I’m at my laptop later I’ll add the full details of the operation. A bit much to type on a phone.

Needless to say you need a Sonoff SV and Tasmota at the very least with Home Assistant or some other smart system with MQTT support.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
37,064
How pray tell have you done this sir?
Most of this is based on this video by DrZzs.


Okay, first things first.

The Alarm

In my case it's an old Spectra 1738 (Paradox) which is hooked up to a third party RF remote setup which was fortunately for me configured as a keyswitch (on/off button basically) on Zone 7. So I could bridge into that to add another "button".

The trickier part was getting the status out. Reading the manual I found that the system supported and Alarm Relay which could be programmed to activate with certain events. So I programmed an Off state when Disarming with a Keyswitch and an On state when arming with a Keyswitch.

My keyswitch config was for a pulse setup (remote button), but there are options for a permanent on/off as well I just didn't want to program a second zone for that functionality.

Now most (pretty sure all) would support a Keyswitch, but the alarm relay might not be so easy to come by. There are also two PGM's on the alarm one of which was in use I suspect by the alarm company so didn't want to touch it. PGM instructions were also very confusing and most want you to connect one part to PGM and the other to auxiliary power which seemed like a recipe to blow something up.

Sonoff SV

First things first would be to flash the firmware with Tasmota. https://github.com/arendst/Sonoff-Tasmota

There is probably a way to do the very same thing with the standard Ewelink setup except for the Pulsetime setting if you need that (if you aren't using a permanent on keyswitch setup).

After installing the firmware you'll need to break out the soldering iron.

Now you have two options to go about this.

1. My understanding is that if you have a wired button going to your alarm (or other device) at the moment you can wire one side to the input + and the other to the output + and then somehow the button function still remains and the Sonoff also works. I DID NOT use this method so you need to watch the video if that's a need for you.

2. If you are purely making a stand alone keyswitch, or like me just plan to bridge into an existing one at the alarm itself then you can simply solder the Input + and Input - to each other. I'm not an electrician or a electronic wizard so can't explain to you why this needs to happen it just does.

Now you need to break off the two resistors on the left side of the Sonoff SV as pictured here...



Twist with a small screwdriver will do it.

Output terminals need to go to your "keyswitch" connection on the alarm system. In my case zone seven. At first I soldered some header pins into the board to easily connect some bread board wires but this had proven to be stupidly unreliable and a waste of time so I implore you to just solder your wires onto the contacts and get it over with.

Power

I'm feeding my SV from the battery connected to the alarm system directly. It's an easy 12V and will obviously keep it running when the power goes off so I have no worries about losing my Smart switch during load shedding or forgetting to topup my prepaid etc.

That would simple be connected at the BOTTOM connectors in this image and they are already header pins so soldering is not an easy option here.



GPIO14

That would be the top and bottom pins here...

Only relevant to do this if you have the ability on your alarm to get the status out. Otherwise skip it and only create a wireless arm/disarm.



That's where the PGM (Alarm Relay) would connect. This will ultimately be only possible after you've done the fighting with your alarm system or you happen to strike it lucky and also have an alarm relay output on yours.

Simply connect it up and then on to the configuration.

Tasmota

Once you have your Sonoff SV flashed and online (most sensible to do this after it's all in place or at least before you are about to put it in place you need to make it look like this.



Why the GPIO4 Relay2? So that you don't get woken up at 3am like me with the alarm turning itself on and off constantly. Again someone super clever could probably explain it but this is apparently by design in Tasmota in the case of power dips or disconnects and doing this prevents false triggers caused by GPIO14. If you aren't using GPIO14 and purely want to add a wireless switch to arm/disarm then you can ignore all this I believe.

Yes it's confusing as it adds a second switch on the web interface and TasmoAdmin will also pick up a second switch (add the SV to Tasmo before making the Relay2 change to avoid that) but it is what it is and you'll likely never use the web interface anyway.

Also for the love of god just put a password on the web interface. This is your house alarm after all.

Now the config begins.

Head to Console from the main menu and enter the following very carefully (copy and paste is safest bet)

Switchretain 1 (remembers the last state of the GPIO14 upon disconnect/reboot/power loss)

Powerretain 1 (remembers the last state of the relay upon disconnect/reboot/power loss)

switchtopic2 alarmstate (this is the MQTT topic for GPIO14)

switchmode1 0 (Turns switch mode follow off, basically makes it a momentary "button" switch)

switchmode2 2 (I'm buggered now if I remember why you need this and sweating too much in this heat to use my brain)

Pulsetime1 10 (this is how long the button will be "held" I initially had a value of 5 and endless issues so 10 is a safe value in my view but you can fiddle if you like, but just start here to make it all work first)

And boom you should have a working on/off using the web interface button.

If you don't have that working yet don't even bother digging further.

MQTT

So now you need to go configure your MQTT settings in the Web Interface or you using Tasmoadmin as I prefer to do.

Then in the console you should start seeing some "state" messages relating to Switch2 that is on/off.

Change that by doing the following.

statetext1 disarmed
statetext2 armed_away

Or go set it in TasmoAdmin.



Now the messages in the console should start becoming a bit more sensible.

"21:22:49 MQT: tele/alarm/SENSOR = {"Time":"2019-01-16T21:22:49","Switch2":"disarmed"} (retained)"

And when triggered should see something like this come up.
"16:55:10 MQT: cmnd/alarmstate/POWER2 = armed_away (retained)"

Home Assistant

So I break my .yaml files up into separate configs just to make life a little easier.

Therefore configuration .yaml should have a line like this included.

Code:
alarm_control_panel: !include alarm.yaml
Then create a file called alarm.yaml in the same directory and it needs to get this contents.

Code:
  - platform: mqtt
    name: Alarm
    state_topic: "cmnd/alarmstate/POWER2"
    command_topic: "cmnd/alarm/POWER"
    payload_arm_away: "ON"
    payload_disarm: "ON"
    availability_topic: "tele/alarm/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"
    optimistic: false
    retain: false
I am not sure if MyBB's code block will format that correctly but normal yaml syntax/convention applies.

DO NOT put retain on true thinking it will be an awesome idea. It's a complete and utter cock up so don't even go there.

And that should do the job and you should be a for away.

Obviously this will only work for one kind of arming and therefore the Arm Home option in Home Assistant is redundant. In fact it shouldn't even work due to the configuration not being there but I'm not about to press the button to test that theory.

****

This configuration applies almost exactly the same for us with a garage or gate the only difference is the GPIO14 is connected to a R20 magnetic door/window sensor. If I remember correctly I had to reverse something for on/off to line up but that's pretty much it.
 

SukkaFoo

Expert Member
Joined
May 18, 2008
Messages
1,046
Most of this is based on this video by DrZzs.


Okay, first things first.
snip
I really should just leave stuff alone that I know nothing about... but that hasn't stopped me in the past.

So I didn't open the panel itself (mostly because I was in a hurry), but there are 4 devices which appear to be connected to the it. One device, I think is the radio, which is communicating with the armed response. Then I suspect there's a GSM backup for comms with them, though I am not sure. And finally there's also the remote receiver. I am just not sure, a) if I am right, and b) what is actually what here. Does anyone know from the (rubbish) pictures below what I am looking at? Also included a pic of the remote, I cannot seem to find what brand it is, perhaps someone else knows that too.
 

Attachments

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
37,064
I really should just leave stuff alone that I know nothing about... but that hasn't stopped me in the past.

So I didn't open the panel itself (mostly because I was in a hurry), but there are 4 devices which appear to be connected to the it. One device, I think is the radio, which is communicating with the armed response. Then I suspect there's a GSM backup for comms with them, though I am not sure. And finally there's also the remote receiver. I am just not sure, a) if I am right, and b) what is actually what here. Does anyone know from the (rubbish) pictures below what I am looking at? Also included a pic of the remote, I cannot seem to find what brand it is, perhaps someone else knows that too.
None of that looks like the actual alarm panel and rather the peripheral radio sender units.

Although there are way too many of them, but as you say one is GSM probably.


****

Aah yes one is GSM.

https://www.fsk.co.za/product-category/gsm-communicators/

And others are the radios transmitters.

https://www.fsk.co.za/product/raptor-433-mhz-single-channel-receiver/

They seem to have some documentation on the website so if you can figure out what alarm panel it is exactly you could probably do the rest.

Then you would more than likely bridge into the same wire paid going from the remote sender unit into the alarm panel.
 
Last edited:
Top