[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug

  • Delvecchio
  • Delvecchios Avatar
  • Autor
  • Pro Boarder
  • Pro Boarder
  • Fabio java
  • Beiträge: 486
  • Dank erhalten: 686
25 Jan 2023 14:21 - 25 Jan 2023 15:07 #239369 von Delvecchio
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
In this short guide, I'll explain how you can configure your ToM to interact with a wifi AC switch / AC plug, or any other device running Tasmota firmware.
Basicaly they are relais modules which can be controlled remotly via a wireless connection.
You can easly find this sort of devices in the market (also am@zon), for a few tens of euros.
They have many formats, but frequently they appear so:
.


.
The last one is more compact and user-friendly.
The first one need some cable connection to work with your electric equipments.


WHY IT'S USEFUL
==============

There are many reasons you could need ToM connected to these devices.
Think, for example, you want to stop traction battery charging if the charger is overheated and restart charging when temperature decreased.
Or you want to stop charging when a desired SOC is reached.
Or, like I did in this tutorial with experiment purposes, to light on a lamp in my room when my Twizy parked in the garage has almost completed the charge.


PRE REQUIREMENTS
=================

1) ToM upgraded to 1.4 firmware, with wifi and mqtt enabled and configured. See ToM's guide from page 41 for details;
2) a wireless switch / plug equipped with Tasmota firmware (version 7 or above are fine).
Remind that "Sonoff" like devices come out the fabric with a proprietary firmware which doesn't support Mqtt protocol.
So to use them, like i did in this guide, you have to upgrade them to Tasmota firmware. Web is plenty of guide about installing Tasmosta fw, so look for one wrote for your device and follow it.
For users who don't want to face with fw update procedure, I suggest to buy a device already running Tasmota fw.


HOW TO CONFIGURE TASMOTA DEVICE
===============================

First configure wi-fi, entering your wi-fi parameters (SSID and securety key) in Tasmota's wi-fi configuration page.
Then configure Mqtt settings. This task requires somer specific instruction.
Reach Tasmota Mqtt page
.

.
and enter your broker address, userid, password and port number. They must be the same you setted in ToM!
.

.
Some words more about "topic" and "full topic" fields.
These must not be the same as ToM's mqtt topics, because they are specific for the device you are using.
In "topic" field enter what you want. I suggest something that remind you the device function. But please use a short string (5/6 chars are enough), because "topic" will be a minimal part of the full topic string and ToM has a limit of 50 chars for aux Mqtt command.
In "full topic" leave the default string "%prefix%/%topic%/" except you use Maqiatto broker or another broker which inserts your userID as part of the topic name.
Only in this case modify "full topic" accordingly. For exemple, with Maqiatto broker full topic will look as follow:
.

.
Finaly, press save and wait until Tasmota device reboots.

Remenber to add the new topic to your mqtt account, if required by your broker.
In case of Maqiatto, you'll have to add "cmnd/your_Tasmota_topic_name/Power" as new topic name in Maqiatto configuration page.


HOW TO CONFIGURE TOM
====================
Wifi and mqtt must be already enabled and configured in ToM. If not, see ToM's guide from page 41 for details.
Open ToM's webserver and go to "Alarm triggers" page.
Add a new allarm to the list accordingly to the item which will control your Tasmota device.
In my case I chose that "Battery SOC" item will trigger alarm when its value will be equal to 97.
.

.
The most important part when controlling a Tasmota device is to configure properly the "Aux Cmd" field, because this one must containt the control mqtt command ToM will send to the Tasmota device.
For normal mqtt broker the Aux Cmd will have this syntax:
"cmnd/your_Tasmota_topic_name/Power 1" if you want to power On the device
"cmnd/your_Tasmota_topic_name/Power 0" if you want to power it Off.
.

.
Only if you use Maqiatto broker or another broker which inserts your userID as part of the topic name, the Aux Cmd syntax will look in this way:
"myemail@gmail.com/cmnd/your_Tasmota_topic_name/Power 1" if you want to power On the device
"myemail@gmail.com/cmnd/your_Tasmota_topic_name/Power 0" if you want to power it Off.
where Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein! will be your maqiatto user ID.
.

.
If you want, for example, to stop charging and to restart it at specific conditions, you need to ad two alarms, one for Power Off condition and one for Power On.
.

.
Please note if you have a device with more than one relais, you have to modify the above syntax specifying which relais you want to control: "Power1" for the first relais, "Power2" for the second and so on.
So, for example:
"cmnd/your_Tasmota_topic_name/Power1 1" if you want to power On the first relais
"cmnd/your_Tasmota_topic_name/Power1 0" if you want to power it Off.

I recorded a short video to show my experiment result. Sorry for the quality of the "white cartoon lamp".


That's all for now!

Feedback & report will be much appreciated.
Letzte Änderung: 25 Jan 2023 15:07 von Delvecchio.
Folgende Benutzer bedankten sich: Snorre, maikt, AndiEcker, green_fox, Jack-Lee, Heiko_Twizy_04-2012, Sherlock

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • green_fox
  • green_foxs Avatar
  • Top Boarder
  • Top Boarder
  • Beiträge: 1159
  • Dank erhalten: 650
25 Jan 2023 16:12 #239378 von green_fox
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
This is so cool, I think I will try this soon :)

A bit off topic: Is it possible to use this for the extension plug too? I am thinking of all the Twizy drivers with the external power charger, if we connect a relais to the extension plug and add the condition "activate at SOC level xy% " the relais can cut off the external charger and thus prevent battery overcharge

Ich fahre mit 100% veganen Strom ;-)

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Snorre
  • Snorres Avatar
  • Platinum Boarder
  • Platinum Boarder
  • Beiträge: 5589
  • Dank erhalten: 3513
25 Jan 2023 16:28 #239381 von Snorre
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug

green_fox schrieb: Is it possible to use this for the extension plug too?


Natürlich.
Schau dir doch mal die Alarmseite auf dem Webserver an. ;)
Mein ToM hat den ExtensionPort noch nicht, aber wenn ich mich nicht irre, ist diese Funktionalität in Firmware 1.4 implementiert.

Twizy Cargo, EZ 07/2014, 100.000 km, Stand 08/2023
Folgende Benutzer bedankten sich: Delvecchio

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Delvecchio
  • Delvecchios Avatar
  • Autor
  • Pro Boarder
  • Pro Boarder
  • Fabio java
  • Beiträge: 486
  • Dank erhalten: 686
25 Jan 2023 16:53 - 25 Jan 2023 16:54 #239384 von Delvecchio
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
I didn't specify it in the guide, but the solution described doesn't need the exapansion connector. So it could be implemented also by first ToM owners.
Further more, Tasmota device still keep the ability to be controlled remotly by its software (phone app too), in the different ways allowed by Tasmota fw.
Letzte Änderung: 25 Jan 2023 16:54 von Delvecchio.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Snorre
  • Snorres Avatar
  • Platinum Boarder
  • Platinum Boarder
  • Beiträge: 5589
  • Dank erhalten: 3513
25 Jan 2023 17:06 #239387 von Snorre
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
@Fabio:
green_fox wants to control an AC plug by a relay connected to the expansion connector.
He likes to replace the MQTT command by a relay.

Twizy Cargo, EZ 07/2014, 100.000 km, Stand 08/2023
Folgende Benutzer bedankten sich: Delvecchio

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Delvecchio
  • Delvecchios Avatar
  • Autor
  • Pro Boarder
  • Pro Boarder
  • Fabio java
  • Beiträge: 486
  • Dank erhalten: 686
25 Jan 2023 17:46 - 25 Jan 2023 17:50 #239397 von Delvecchio
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
Tkank you Martin.
Ok.
It's possible. He has to choose pin1/2 as alarm action and set that pin as output. I posted a suitable schematic for connect a relais to the expansion port.
Anyway I think the solution described here is simplier and more flexible. But it's a matter of taste. ;)
The downside is that it requires an active internet wifi connection.
Letzte Änderung: 25 Jan 2023 17:50 von Delvecchio.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • stromkreisparadies
  • stromkreisparadiess Avatar
  • Platinum Boarder
  • Platinum Boarder
  • Markus
  • Beiträge: 3747
  • Dank erhalten: 1011
25 Jan 2023 18:02 #239400 von stromkreisparadies
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
wouldn't it be better to stop the charging from the CAN side?
if you switch off the power, the Twizy is able to start and drive with plugged power. althought there are no external devices and rewiring needed.

Grüße von Markus

-> Twizy Technic, LED Tagfahrlicht, LED Innenbeleuchtung, Sitzheizung, Radio mit Freisprecheinrichtung
-> Brammo Empulse R
-> 2x Elektrofahrrad (Stadt-Trekking und Downhill für den Wald)

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Goldbacher
  • Goldbachers Avatar
  • Platinum Boarder
  • Platinum Boarder
  • Beiträge: 3626
  • Dank erhalten: 1596
25 Jan 2023 18:04 #239401 von Goldbacher
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug

Think, for example, you want to stop traction battery charging if the charger is overheated and restart charging when temperature decreased.

If the Twiz O'Meter can write CAN, it should be easier and better because the fan stays on:
OVMS-Plugin (with code)

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Delvecchio
  • Delvecchios Avatar
  • Autor
  • Pro Boarder
  • Pro Boarder
  • Fabio java
  • Beiträge: 486
  • Dank erhalten: 686
25 Jan 2023 18:22 - 25 Jan 2023 18:24 #239409 von Delvecchio
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
Interesting info. Thanks.
Unfortunatly ToM doesn't write to Canbus for my choice.
Charging control was just an idea about how to use the alarms feature.
Letzte Änderung: 25 Jan 2023 18:24 von Delvecchio.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Sherlock
  • Sherlocks Avatar
  • Senior Boarder
  • Senior Boarder
  • Beiträge: 114
  • Dank erhalten: 65
12 Apr 2023 17:54 #242921 von Sherlock
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
Hi Fabio,

Rather than writing to you privately, I'm posting the problem I encountered. This can be useful for everyone.


Today, I configured a Tasmota plug (MQTT and Wifi settings already done last week). Once the configuration done, I wanted to do a test (cut the load when SOC reaches 57%). So I opened the Webserver's Alarm Page to add a new alarm.

Here is the detail :


Item: Battery SOC

Condition: equal

Ref value: 57
(the SOC was at that time at 55%).

Action: Pop-up

Send MQTT: activated

Aux Cmd: myemail/charge/Power 0


Finally, I completed the procedure by pressing "Add to list". This new alarm immediately appeared in the alarm table.

This done, I turned off the ignition, then I plugged the power cord into the Tasmota plug. Charging started and ToM turned on again. As soon as the SOC reached the programmed value of 57%, a pop-up window opened as expected. However, charging did not stop. I unplugged the power cord and turned the ignition back on to check ToM's Alarm Page. I noticed that in the table of alarms the "COMMAND" box was empty. Is this normal?

Why didn't the charge stop once the SOC reached 57%? Did I make a mistake?


To help you understand what I did, I attached some screenshots.


Best regards



Anhänge:

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Delvecchio
  • Delvecchios Avatar
  • Autor
  • Pro Boarder
  • Pro Boarder
  • Fabio java
  • Beiträge: 486
  • Dank erhalten: 686
12 Apr 2023 18:19 - 12 Apr 2023 18:29 #242922 von Delvecchio
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
The command blanked isn't normal. In this state no command was sent to mqtt and therefore charge didn't stop.
What ToM fw version are you running?

I assume from the screenshot you are using maquiatto, so you have to add also "cmnd" prefix:
myemail/cmnd/charge/Power 0
Letzte Änderung: 12 Apr 2023 18:29 von Delvecchio.
Folgende Benutzer bedankten sich: Sherlock

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Sherlock
  • Sherlocks Avatar
  • Senior Boarder
  • Senior Boarder
  • Beiträge: 114
  • Dank erhalten: 65
12 Apr 2023 18:43 #242923 von Sherlock
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug

Delvecchio schrieb: The command blanked isn't normal. In this state no command was sent to mqtt and therefore charge didn't stop.
What ToM fw version are you running?

I assume from the screenshot you are using maquiatto, so you have to add also "cmnd" prefix:

myemail/cmnd/charge/Power 0



Thank you Fabio.

Yes, I use Maqiatto.

For sure, I forgot "cmnd"...:blush: I'll try again later this evening and I'll report.

My ToM still runs firmware 1.4 . I'll try to upgrade him to 1.45 tomorrow.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Delvecchio
  • Delvecchios Avatar
  • Autor
  • Pro Boarder
  • Pro Boarder
  • Fabio java
  • Beiträge: 486
  • Dank erhalten: 686
12 Apr 2023 18:57 #242924 von Delvecchio
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
Yes it's better to upgrade, because in the early 1.4 version, the saving of the Aux command wasn't enabled.
So the command is lost after a power-off.
I think this is the main reason of the problem.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Sherlock
  • Sherlocks Avatar
  • Senior Boarder
  • Senior Boarder
  • Beiträge: 114
  • Dank erhalten: 65
12 Apr 2023 19:10 #242925 von Sherlock
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug

Delvecchio schrieb: Yes it's better to upgrade, because in the early 1.4 version, the saving of the Aux command wasn't enabled.
So the command is lost after a power-off.
I think this is the main reason of the problem.


I'm sure you are right.

I just tried with an alarm at 56 % , with myemail/cmnd/charge/Power 0 written in the Aux command. Once again, the pop-up appeared at 56 % but the charge didn't stopp.

I'll upgrade tomorrow.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Delvecchio
  • Delvecchios Avatar
  • Autor
  • Pro Boarder
  • Pro Boarder
  • Fabio java
  • Beiträge: 486
  • Dank erhalten: 686
22 Apr 2023 21:45 - 22 Apr 2023 21:49 #243312 von Delvecchio
[Twiz O'Meter] How ToM can control a wifi AC switch / AC plug
After some (:laugh: ) tests with Sherlock, we found where the problem was.
Tasmota firmware doesn't like maqiatto topic format!

So, if you want to drive a Tasmota device with ToM, you have to use another mqtt broker.
With Sherlock, we successfuly configured mqtt.dealgate.ru.
It's free and, in my point of view, also more complete then maqiatto.
The downside is that you have to face with some russian translations to create the account. But nothing than an online translator cannot do.
Letzte Änderung: 22 Apr 2023 21:49 von Delvecchio.
Folgende Benutzer bedankten sich: Sherlock

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

   Become a Patron