Controlling a 3-way power switch with relays and Odroid

Share here your ideas for new projects

Moderators: odroid, meveric, mdrjr

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby mad_ady » Thu Mar 01, 2018 5:25 am

So you convert mqtt to can packets (of your own encoding)? One additional advantage is that you can hook up your car and control its windows/wipers/lights/engine/brakes/etc with the same system [emoji14]

But I agree. Wifi is a pain
User avatar
mad_ady
 
Posts: 4731
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby Jojo » Thu Mar 01, 2018 11:41 pm

mad_ady wrote:So you convert mqtt to can packets (of your own encoding)?

Exactly. Of course this requires some knowledge and additional work to be done, but on the other hand I am now using a very well known and documented technology with high flexibility.
My MQTT-to-CAN gateway subscribes to all messages, that have something to do with my windows (setting cover positions, setting cover drive times for up/down).
Example: lets say I've got three blinds (in fact I have 10), so the "set"-MQTT-topics are:
- living_room/window/cover/position/set/
- living_room/window/cover/time_up/set/
- living_room/window/cover/time_down/set/

- dinning_room/window/cover/position/set/
- dinning_room/window/cover/time_up/set/
- dinning_room/window/cover/time_down/set/

- kitchen/window/cover/position/set/
- kitchen/window/cover/time_up/set/
- kitchen/window/cover/time_down/set/

- default/window/can_id/set/
So I subscribe to "+/window/*". When I receive a valid message, I decompose it piece by piece to determine what should be done for which window.
Then I create a CAN message. I use standard 11-bit identifiers (to keep traffic as low as possible), where I use the higher 5 bits as "slave select" and the lower 6 bits as "command". There are enums, that "encode" the room-name- and command-portion into a corresponding CAN identifier.
The CAN-"slaves" are much simpler. Each room/CAN-"slave" has set up CAN-ID-filters to only receive message that are really addressed to it. This just prevents the CPU to receive and process unwanted messages. The CAN-"slaves" also have enums to "decode" the CAN identifier to determine what should be done.

All this might sound complicated like hell. But it isn't, really. Basically it is just converting strings (MQTT topics) into numbers (CAN identifiers). Of course all this only makes sense, if you have much more then one or two windows/slaves/clients... I anyone is interested, I can share all this stuff.

Greetings
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby mad_ady » Thu Mar 01, 2018 11:56 pm

Do you have a static mapping name - number, or do you use some hashing algorithm to derive the number that corresponds to a name? If you use hashing - are you free of collisions?

It's an interesting approach, though I'm not sure what the advantage of using CAN is (instead of ethernet/ip - since you had to wire your blinds anyway)?
User avatar
mad_ady
 
Posts: 4731
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby Jojo » Fri Mar 02, 2018 7:24 am

mad_ady wrote:Do you have a static mapping name - number, or do you use some hashing algorithm to derive the number that corresponds to a name? If you use hashing - are you free of collisions?

No, it is static. I just numbered the rooms and windows in my house one after another. By default, the room-portion of the CAN ID is 0, so I can change the CAN ID of each room on-the-fly, as long as it is unique on the bus. This is something I need to take care of.

mad_ady wrote:It's an interesting approach, though I'm not sure what the advantage of using CAN is (instead of ethernet/ip - since you had to wire your blinds anyway)?

Well, for some reason I don't like ethernet, when it comes to fail-safe and sensitive things. Especially the network technology is changing rapidly and it will do so in the future. There are new standards, new protocols, new devices every few years (at least it feels so). CAN is a quite old but very proven protocol. Easy setup, robust, unexpensive, flexible.
I am planning to live in my house for at least two or three decades. Thats why I've choosen a technology, that has a higher chance to remain as it is. But of course it is a matter of opinion and personal preferences :) .

Greetings
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby joaopequeno » Fri Mar 02, 2018 5:45 pm

@Jojo

Ok.
The solution i found have the problem of getting the system only worlking by remote and not locally, this solutions seems to be good because work both with remote and locally.
I even have found a brand that make some good remotes but they are very expensive (you can check it here http://blebox.eu/en/home/8-shutterbox-r ... phone.html)
Your solutions seems to be almost the same.
I will start to implement it to use with home assistant. about hte programing perhaps i will have some doubts but i will check it later.
Do you have the schematic for the ESP8266 with the relay module?

Thanks for the help
joaopequeno
 
Posts: 3
Joined: Tue Feb 27, 2018 8:51 am
languages_spoken: english

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby Jojo » Fri Mar 02, 2018 10:24 pm

joaopequeno wrote:@Jojo

Ok.
The solution i found have the problem of getting the system only worlking by remote and not locally, this solutions seems to be good because work both with remote and locally.
I even have found a brand that make some good remotes but they are very expensive (you can check it here http://blebox.eu/en/home/8-shutterbox-r ... phone.html)
Your solutions seems to be almost the same.
I will start to implement it to use with home assistant. about hte programing perhaps i will have some doubts but i will check it later.
Do you have the schematic for the ESP8266 with the relay module?

Thanks for the help

Hi,
in general, I would try to not go for a "closed" system from a specific manufacturer. All this "smart home" stuff if growing like hell atm, and every manufacturer comes with its own specific solution. This really sucks, because they are (of course) not compatible to each other. Thats my main reason, why I build it myself and based on very open standards like MQTT and CAN.
About the schematic: I don't understand what you want. "My complicated" schematic is already here. If you want to connect an ESP8266 directly to a relay module, you just need a hand full of wires.
This is not meant offensive, but don't you think that you should start with something easier and less critical then home automation?
How to ask questions the smart way:
http://www.catb.org/esr/faqs/smart-questions.html
Jojo
 
Posts: 524
Joined: Mon May 18, 2015 12:13 am
Location: Germany
languages_spoken: english, german
ODROIDs: C1, C1+, C2, HC1, HC2, VU8C

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby mad_ady » Fri Mar 02, 2018 10:35 pm

Offtopic sidenote:

Last night I had a problem with my router (it stopped responding to DHCP for some reason). My Odroid which hosts Homeassistant restarted when it lost its DHCP lease, but I have a script on boot which checks for connectivity/IP address, and it there is none it forces a static address (the same one handed out by DHCP). After this it was stable. The odroid which hosts my dashboard (has the 3.5" LCD) and also controls the heater didn't have that script. It rebooted because of its watchdog when it lost its network configuration and remained in a boot loop because it was unable to get an IP (and I have a script which makes it reboot if it doesn't have an IP). This morning the rebooting tipped me off that something was wrong, but this also means that I had no heating last night because the odroid which controlled heating was rebooting. There were -15C outside last night, but thanks to building insulation temperatures didn't go below 25C inside. So, I dodged a bullet there. Had it been colder, I would have been murdered by my wife.
So, as @Jojo said, home automation can be a risky business... :D
User avatar
mad_ady
 
Posts: 4731
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby odroid » Fri Mar 02, 2018 10:37 pm

:o :D :D
User avatar
odroid
Site Admin
 
Posts: 28878
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Controlling a 3-way power switch with relays and Odroid

Unread postby mad_ady » Fri Mar 02, 2018 10:41 pm

No worries, I installed the extra script, so next time this happens I should be ok.
User avatar
mad_ady
 
Posts: 4731
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Previous

Return to The Ideas

Who is online

Users browsing this forum: No registered users and 2 guests