[RELEASE] Tasmota Sync - Native and Real-time Synchronization between Hubitat and Tasmota 11 or later

Could you share the commands that your node-red device sent to Tasmota to get the fan working? Would be helpful to me to see these.

Apologize for the delay, had a busy 4 hour window at home yesterday and just saw this while at work on my phone. Remoted in and got some screenshots of my node-red stuff.

Screenshot_20220830-083541_AnyDesk

Screenshot_20220830-083551_AnyDesk

All of these are hubitat going to the device, basically formatted to take the hubitat virtual device change and chop it up into a message formatted in a way that Tasmota gets a TuyaSend# command and parameter. I have a separate flow for each device, thus a subflow that is the same for all, but different input and output depending on the fan in which room.

The difference between TuyaSend1 vs 4 is 1 is used to change boolean values (the fan power toggle on or off) and 4 to change Enum values, the fan speed. When the fan speed is changed in hubitat, Tasmota gets both a speed change and a power change. If the speed is anything but off, node-red sends an "on" command and a second command with the associated speed to Tasmota. The "3,3" would equate to the DpId 3 (which is the fan speed Enum value), and 3 is the value to apply.

These two are the reverse direction, where it receives the TuyaSend commands and parameters, reorganizes it into a SetSpeed command, then outputs it to the virtual device in hubitat.

Sorry for the poor organization. Doing anything on a phone vs computer is always miserable, but figured I'd work with what I have. I can edit and clean it up later if need be.

Is this an accurate summary?
TuyaSend1 Toggle Power On/Off
TuyaSend4 3,0 - Fan Speed Low
TuyaSend4 3,1 - Fan Speed med-low
TuyaSend4 3,2 - Fan Speed med
TuyaSend4 3,3 - Fan Speed med-high
TuyaSend4 3,4 - Fan Speed High

Bearing in mind I may not fully understand your environment, you could try this.
Add additional relays to your device, doesn't matter that they are not connected to anything.

Rename the buttons with this command.
WebButton2 Fan Power
WebButton3 Low
WebButton4 Med
WebButton5 High

Interlock the fan speeds so only one can be active at a time.
Interlock 3,4,5
Interlock on

Install a rule that will send the necessary Tuya commands when the relays are activated.
rule1 ON Power2#State=0 DO Backlog TuyaSend1 0 ; Power3 Off; Power4 Off; Power5 Off ENDON ON Power2#State=1 DO TuyaSend1 1 ENDON ON Power3#State=1 DO TuyaSend4 3,0 ENDON ON Power4#State=1 DO TuyaSend4 3,2 ENDON ON Power5#State=1 DO TuyaSend4 3,4 ENDON
rule1 ON

Turning on relay 4 (Med) will send the TuyaSend4 3,2 command for example.

I may be wrong on the specifics but I think this approach would work. Does not give you the full fan interface but sounds like you never had that anyway.

In this scenario you would use the Multi-Relay driver and not the Fan with Dimmer. I could make a N Relay driver with Dimmer for you that would work but I won't maintain it going forward as it's just too niche.

Hope this helps.

Gary,

It is very interesting your new approach at installing AND using Tasmota at it´s full potential.

I´ve been doing some tests with a specific device I bought for a specific purpose, but havent´been successful at my trials.

I bought a Sonoff POW Elite 16A switch, and after some struggling I was able to flash it with Tasmota 12.1.1.

It is working as expected, but there is some functionality I can´t make to work;

If I define a Rule where I want something to happen (turn on a switch, send a notification, register date/time, etc.) when a device starts working (Power > 0) the trigger would not work. (Important, the switch is already On, but the device connected into it turns on and off depending on other conditions).

I have noticed that when I manually switch such device with your drivers, I can see a change on the switch status (on/off), but the power would not change unless I do a Refresh.

Any ideas? Am I doing something wrong?

Thanks

Thank you. It seems to be working well for most people and I really like Tasmota so I'd like to see it get a bigger following on Hubitat.

After defining the rule did you turn the role on? rule1 on for example. Please post the rule that is not working.

Changes that get made at the Tasmota UI get reflected by the presence of Rule3. So the most important thing is that you have done a tasmotaInjectRule() which it sounds like you have.
Rule 3 sends changes on two different timescales. Common things like power, color, dimmer, fanspeed etc are monitored and if a change is detected they get sent immediately and you will see the change take effect in Hubitat in 1-2 seconds in my experience.
The second timescale is the one that I think is applying to you. This affects sensor values such as current, power, temperature, pressure etc. Tasmota measures these every second but if we sent them to Hubitat every second it would be very detrimental to Hubitat. Instead these sensor values only get sent at the "Telemetry Period" and in the case of TasmotaSync will only get sent if at least one of the values has changed.

If I remember correctly the TelePeriod default is 300 (seconds) but can be changed to anything in the range of 10-3600 using the TelePeriod command. The TasmotaSync driver display the current TelePeriod in the State Variables.

One important note is that the "Current States" area refreshed automatically (almost always) but the State Variables only refreshed on page refresh.

Bottom line, do a tasmotaInjectRule. Set the TelePeriod to 10. Apply a load to the device and you should see changes occur. If not, turn up the logging level and look at the logs which should yield a reason.

1 Like

Started to tinker with the rules and setting up a relay system. I think I'm making progress, but have hit the "end of my day" already, so it's off to shower and sleep for me. One snag though. When I use the physical buttons, tasmota recieves a "tuyareceived data" thing that basically has the serial data for each fan speed. I put that into a rule and had it do a "power2 on" rather than an MQTT publish. This synced up the relays on the web gui with the physical switch status, and your suggested rule allowed web gui changes to go the physical switch just fine. However, when the fan is turned off, the "speed relay" associated also turns off. When the fan is turned back on, the physical switch remembers the speed it was on last, but Tasmota doesn't, and apparently doesn't receive a "tuyareceived" status to update it.

I haven't began the "link to hubitat" process yet, so forgive me if this would be alleviated during that, but would that "missing speed data" create an issue on Hubitat's side of things?

I'll continue to tinker and either come back with issues, or return with a grand success story that I'm sure somebody somewhere will be happy to find via the google machine. Thanks for your advice and suggestions thus far. I'll keep you posted!

You would need to use a variable to preserve the speed each time it is changed.
ON Power3#State=1 DO backlog TuyaSend4 3,0 ; mem1="3,0" ENDON

and then restore the speed when the power is restored.
ON Power?#State=1 DO TuyaSend4 %mem1% ENDON

or if we are talking about a literal power restore you would use something like this.
on power1#boot DO TuyaSend4 %mem1% ENDON

Hope that helps.

I´m sorry for not being clear, when I mentioned I defined a Rule, I was talking about Hubitat Rule Machine, not a Rule on Tasmota Device Console.

Now after doing a TasmotaInjectRule(), and after setting TelePeriod to 10, it works as expected (Great!!!), but now I have a weird behaviour;

I´ve set a Rule Machine rule sending or speaking a notification everytime a water pump turns on, and what it does, it sends/speaks a message every 10 seconds for 3 minutes +/- before the water pump turns off, and then I just get one message informing me that it has turned off.

Still in the testing process to try different rule formats/apps to see if I can jut get one message / instruction when it turns on, and one when it turns off.

Any ideas?

Thanks for your help

Rgr. Easiest way, would be to use the Notification manager. It has the ability to limit the number of notifications within a given time period. Something like this.

Gary,

Thank you again for your advice with the fan stuff, both in this thread and the other. I have yet to take the time to implement your latest suggestion, I'll get to that one shortly.

In the meantime, I've moved along to another one of my node-red integrated switches to try and migrate them over to Hubitat / Tasmota Sync exclusively. This one is a Treatlife (Tuya) 3-way switch (Template can be found here). I have tried to set it up as both a single and a dual relay switch and can't seem to get it to play along well (once again).

Here's the rundown. Applying the listed template, it will show up as 2 relays on the UI. One reflects a "sensor" line that essentially reflects the actual status of the load, either on or off. The other is the actual physical relay, either on or off (or in a 3-way application, more like A or B). When set up with Tasmota Sync, power commands are sent to Relay 1, or the sensing line. That's fine, because I want on commands to tell the "off load" to turn on. Set up a tasmota rule that when Power1 changes, toggle Power2. Easy day.

BUT! When somebody comes along and toggles one of the "dumb" switches on the other end of the circuit, it flips the "A/B" relay in the switch, which toggles the "load sensing" relay to ON, which activates the rule to toggle power2, lights turn off, sensing relay flips, rule1 activates, and then we have a flickering rave party.

So I thought, maybe I can get Tasmota Sync to "listen" to Power1 for any changes and reflect that state in the UI, but then send on/off commands to Power2 (the physical relay). That would allow the UI to always reflect what the "sensing load" shows, but then only impact the actual relay toggle when commands are issued.

But then that essentially means sending commands to Power2, but then waiting for commands to return via Power1. As with the fan, I started picking through the driver to see if I could figure it out and figured I'd be better off just coming here to ask first.

Thank you in advance! I hope my antics aren't giving you too much of a headache and it's seen more as a test of creativity, flexibility, and perseverance! :stuck_out_tongue_closed_eyes:

If I understand correctly it sounds like you are unable to get the 3 way switch configuration to work properly before adding Hubitat to the mix?
I don't have any 3 way switches but here is a thought that might work.
Configure them as two totally independent switches such as.

Switch1 @ 192.168.0.120
Switch2 @ 192.168.0.121

On Switch1
ON Power?#State=0 DO webquery http://192.168.0.121:80/cm?&cmnd=power off ENDON
ON Power?#State=1 DO webquery http://192.168.0.121:80/cm?&cmnd=power on ENDON

On Switch2
ON Power?#State=0 DO webquery http://192.168.0.120:80/cm?&cmnd=power off ENDON
ON Power?#State=1 DO webquery http://192.168.0.120:80/cm?&cmnd=power on ENDON

This should keep the two switches in sync.

Then connect them to Hubitat as a single relay switch.

Maybe better ideas but there is something to think about.

P.S. You can just paste these commands into your browser to test them out before putting them into a rule. http://192.168.0.120:80/cm?&cmnd=power off

I suppose I didn't describe it quite right. The "3-way" configuration is merely a description of how the internal workings of the switch works. It takes the incoming line power and directs it to a load A wire or a load B wire. The load is energized if the wires further down the line in the dumb switches are "in line" with the load. This is opposed to a single pole that is either toggled to "load connected" or "load not connected." I have only the one smart switch in the entire lineup, then a dumb 4-way switch at the top of the stairs, followed by a dumb 3-way switch at the end of the upstairs hallway, then the actual lighting load, then the neutral line goes back to the breaker panel. Essentially the 3-way switch serves as a standard on/off toggle (in reality it's an A feed / B feed), but Tasmota can use the smart switch's "sensing" line (GPIO14) to detect when one of the dumb switches upstairs has been flipped, completing the circuit and energizing the load, then marking the "sensing" relay as being "on" while the "relay toggle" (the A/B toggle) remains in its original position.

But here's where it gets (more) complicated. Tying that into Hubitat. If I use the "sensing line" as the signal to the hub so the UI shows "on" when the load is on, then sending commands to the load sensing relay would require flipping on the physical relay upon a change in the load sensing line. For example, load is energized, sensing line is "on," hubitat sees it as on. Send off command, tasmota receives it and flips the load sensing relay to off, a rule toggles the physical relay to toggle to whatever side it wasn't on, load is deenergized. Perfect.

But somebody comes along after that and flips a dumb switch, the load is energized. The load sensing relay goes from off to on, the rule triggers and flips the physical relay, which then turns the load off again. The sensing line sees this change and flips accordingly, sends another toggle to the physical relay, rinse and repeat.

Unfortunately, I'm traveling the rest of the week and won't be home to tinker, but figured I'd post an update to this little venture anyway. (As a separate aside, been working with the fan controller and have made progress. Far from perfect or consistent, but I'm getting there.)

Hi @garyjmilne

Thank you so much for the work you have done. I wanted to ask before I even tried to make changes. I have a custom device running Tasmota that measures (ultrasonic sensor) the distance from my garage roof to the floor. Using a Tasmota rule, if the distance is greater than say 150cm then the car is not in the garage. If less then there is a car in the garage. This rule either turns a switch on (car is present), or off (no car)

What could I use in the Tasmota sync drivers to replicate this and is the distance sensor supported?

This is how it is showing currently in Hubitat

Hi Greg, in theory that should be pretty easy. I have some SR04 so I know they work as long as you have the sensors version of Tasmota installed which you already do by the sound of it. I'll refer you over to the universal sensor thread which you can find [here.] ([Released] Tasmota Sync - Universal Sensor Driver - #15 by garyjmilne) for future discussions around this topic.

Here is what you need to do.

  1. Change the IP on the DRIVER of your existing "Greg Car - Universal Parent". The field is called Device Network ID. This lets you keep your old config while you try out the new one.

  2. Install my Tasmota Sync Universal Sensor Driver per the instructions and make sure you add the IP of the Tasmota device and the Hub. Looks like you have a switch on your Tasmota device so you would use the Universal Sensor driver with Single Relay.

  3. Do a refresh and it should populate the attributes.

  4. Once it has detected your ultrasonic sensor it should populate an attribute called distance if I remember correctly.

  5. Once that is working you can now do the tasmotaInjectRule and the tasmotaTelePeriod and it will send updates from Tasmota back to Hubitat automatically.

  6. When you are creating Hubitat rules around the sensor values you need to use the custom attribute value as your trigger.

I may have missed something so you can find the documentation here.

Sounds complicated but once you have been through it you will find it's quite easy to do.

P.S. You need to upgrade to Tasmota to version 11 or later. I'm using 12 on all my devices without any issue. Here is a guide if you need any help with that. https://github.com/GaryMilne/Hubitat-Tasmota/blob/main/How%20to%20Upgrade%20from%20Tasmota%20from%208.X%20to%2011.X.pdf

1 Like

It's a difficult one to think through without an actual device to tinker with. What I would do is figure out in english language terms what I want to happen in each of the scenarios.
Relay On, Sensing On - Receives Sensing Off
Relay Off, Sensing On - Receives Sensing On
etc.

My guess is you will need to use either a variable (%var%) or another relay to store "the truth". You might need to use the oneShot capability of rules to prevent the race condition that you are seeing. If you need more complex expressions in rules Tasmota has a version that allows that.

P.S. You can concatenate the values of the 2 relays into a single variable (like I do in my driver) and then use that single variable to decide what to do.

Sorry that I can't help more.

Did it all work out O.K.?

Hi @garyjmilne

I managed to change over the Tasmota device with the ultrasonic sensor and all is good. What I did want to ask you is, under the State Variables it has a LastSensorData and this does not update the time unless I click on refresh. Does this have anything to do with the device updating to HE. The values are changing in the Current States but the dashboards don't seem to be updating unless I re-load the dashboards? Any ideas?

Greg, glad it is working for you. I understand your confusion re:[quote="greglsh, post:157, topic:93651"]
under the State Variables it has a LastSensorData
[/quote]
Hubitat gets updated in two ways with this driver.

  1. After doing an injectTasmotaRule the Tasmota device sends the data (if changed) unsolicited based on the TelePeriod. When this happens it updates the lastTasmotaSync field.
  2. When doing a 'Refresh' via the Hubitat interface or when Polling is configured. When this happens it updates the lastSensorData.

Note that the state Variables area of Hubitat does not refresh automatically like the Current States does.

1 Like

Anyone interested in the Tasmota Sync drivers should also take a look at this companion app I wrote to distribute commands to multiple Tasmota devices at the same time. Makes a lot of things easier.

Hi @garyjmilne

Wanted to ask you I have Sonoff Tx light switches which have been flashed with tasmota. I have changed them to your sync driver. What I have is single, double and triple switches. I can operate the "primary" switch fine from the dashboard, but how would I "access" the second and third switches from the dashboard like I had before.

So I basically need to add a button so that I can switch2 and switch3 on and off?