Diary of a newbie - you can learn from my mistakes

I don’t what I’m doing but thought I would record lightbulb moments for others to learn from. Apologies if I am leading you astray, my intentions are good, and maybe more experienced Apilions will reply with a redirect!

2 Likes

DEVICES: This option is the last on the dashboard. Go here to sync your internet widgets, little white boxes to Apilio. This I did using the sign-in details that I have used to install my widgets (eg Tuya App log in) and was soothed when all my Tuya devices immediately loaded.

However I have been finding I can get a logicblock to run as intended once and never again, and have begun to use the times in conditions to try and get ahead. All very frustrating.

Tonight I returned to DEVICES and discovered if I click on the name of one, there is an edit button at the bottom of the screen whereby you can turn on monitoring. I am guessing that this means Apilio will monitor that facility on that widget. So slide the button across to switch on monitoring. You can even drag the facility to the top of the list.

Don’t forget to save.

So maybe now I can make progress.

:shushing_face: I won’t tell if you don’t

3 Likes

MY VERY FIRST TUYA RECIPE:

Using 2 internet sockets, with nightlights of different colours, my aim was that if the red plug is turned on using the Tuya App, then Apilio would turn on the orange plug.

1 condition, 1 logicblock

CONDITION - Select TUYA as the type. Give title. Select the device, for me its Red Plug ( as that’s how I have named it in the Tuya app) This should load a couple more fields, Status: and then and “it must be” I think different manufacturers may have different variations available. For mine the Status is “switch one” and it must be is “on”

Finally tick the box that means that if this condition is met it can trigger a logic block

LOGICBLOCK So I started a new logicblock and labelled it. Next all the conditions I have created as triggers were listed, so I ticked in the box with the right name.

Going down to the actionchain I selected TUYA and again selected my device - mine is the orange plug - and this time you choose an action and a value. Again these vary from device to device, mine were switch 1 and on.

Save.

Finally using my phone, I turned the red socket on, using your tuya app and… Ta da… orange plug comes on and the celebrations start.

:partying_face:

(as usual, if I have got this wrong, please will someone experienced correct me)

2 Likes

Awesome - thanks for sharing! :star_struck:

1 Like

This sort of post is so helpful for newbies, thanks so much for sharing!

RECIPE 2 - Using Temperature as a condition, with a logicblock with an action designated for if the condition is true OR if the condition is false The emboldened text is the differences between my first recipe and this one.

Using a temperature sensor (thermometer) and 1 internet socket, with an imaginary heater (nightlight orange) plugged IN, my aim was that if temperature is below 17 degrees, then Apilio would turn on the orange light and if it is not it would turn it off.

1 condition, 1 logicblock

CONDITION - Select TUYA as the type. Give title. Select the device, for me its Orange temperature( as that’s how I have named it in the Tuya app) This should load a couple more fields, “status” this time is var temp and the “must be” is less than finally add the number - for me 17

Finally tick the box that means that if this condition is met it can trigger a logic block

LOGICBLOCK So I started a new logicblock and labelled it. Next all the conditions I have created as triggers were listed, so I ticked in the box with the right name.

Going down to the actionchain I selected TUYA and again selected my device - mine is the orange plug - and this time you choose an action and a value. Again these vary from device to device, mine were switch 1 and on. This is for when the condition has been found true -the room is lower than 17

This time I added an action for if the temperature higher than 17. The condition has been found false:

Tuya selected/Device selected (orange plug again)/Action selected(switch one)/ and finally the “value” is off**

Save.

Testing temperature condition is a little hard to control. I chose my room temperature as the lower variable and then when I needed the temperature to go up I tucked the thermometer in bed with me! I’m sure under one’s arm would be as good!

:face_with_thermometer:

1 Like

NEXT DISCOVERY

In the normal world when you say “the plug should turn on, when the outside reading is below 13”, it is obvious that “the plug should turn off” when the outisde temperature goes above 13. But in this world of automation it looks like you actually have to create variables, conditions and finally a logicblock to make this happen.

So I have one logicblock with an action for when the outside temp is below 13. and I have created a second logicblock with an action for when the outside temp is above 13.

I followed the pattern from the videos to use IFTT to change the variable when Weather Underground triggered. Found here

https://community.apilio.com/t/getting-started-an-introduction-to-apilio/19

I have a feeling that this might only be necessary when incorporating IFTTT into the logic? as the native Tuya devices do include the opportunity to create an action when the the conditions are found to be negative.

:sunglasses: Jt

1 Like

Thanks for posting this, it can seem complicated to setup your home automation sometimes, I have just gone through some pain replacing IR sensors so believe me I sympathise :face_with_head_bandage:.

In this case though I am not sure you need a second logicblock. Surely if the condition being tested is <13 then you would just use the negative action chain in the same logicblock to turn off. So it’s one triggering logicblock testing for below 13. Then once’s it’s tested if it’s true the +ve action runs (turn on) but if it’s false the -ve action runs (switch off). Does that make sense? DanT

1 Like

Sorry for the reply delay - I’ve been moving all the smart devices out of the lab (my room) to be in their permanent positions with heaters plugged in. Everything has gone well except the boolean variable for the outside temp is only checked once a day and true updates to true.

As you see, it is never “false” - so even when I know 17 degrees outside the variable doesn’t change, and more importantly doesn’t stop the heaters from turning on!

The related condition is this:

And the IFTTT action:

I had hoped that setting a 30 minute timeout on the condition would reset it to false so that IFTTT would update but I get this sort of message. should I evaluate the logicblock.

I can’t seem to get further. How can I get the boolean to go to false when it is above 13 outside, please?

:sunglasses: Jt

This presents a nice challenge, so here is my suggestion.

I assume that you need an action to run when you go below your 13C threshold, and another one to run when you go back above it, and that these actions should only run when there is a transition. There therefore needs to be a way of getting the outside temperature into Apilio (for which i would use Weather Underground via IFTTT, and store the actual temperature rather that use a boolean) and also some logic to know not only whether you are above or below this temperature, but also keep track of whether you have already gone above/below so that you don’t repeatedly run actions unnecessarily.

I believe that the following should do all that.

  1. Create a numeric variable in Apilio “outside_temp”

  2. Create Apilio time condition “every_5_min” to trigger every 5 min (or whatever frequency you prefer) – use a cron time event with the value “*/5 * * * *” to do this.

  3. Create Apilio logicblock “read_outside_temp” that is triggered by “every_5_min” with the IFTTT action “get_outside_temp”

  4. Create an IFTTT applet “Update Outside Temperature” that has:
    IF receive an event from Apilio, with the event name “get_outside_temp”
    WITH Weather Underground current weather
    THEN Apilio, Update a numeric variable in Apilio, select “outside_temp”, set the value as the ingredient “CurrentTempCelsius” from Weather Underground

At this point, you should get the variable “outside_temp” updated every 5 min to the current outside temperature

  1. Create an Apilio numeric variable “threshold_temp” and set this to be equal to 13. This is the trigger point for your actions, and can be updated if you wish

  2. Create an Apilio numeric condition “below_threshold” to trigger whenever “outside_temp” is less than “threshold_temp”

  3. Create an Apilio numeric condition “above_threshold” to trigger whenever "outside_temp is greater or equal than “threshold_temp”

You now need some logic to know whether you have already gone above or below the threshold, to stop repeated switching on/off when the transition has already happened.

  1. Create an Apilio boolean variable “temp_above_threshold” and set this to TRUE or FALSE depending on the current temperature

  2. Create an Apilio condition “already_above_threshold” that requires “temp_above_threshold” to be TRUE. Make sure this condition does NOT trigger logicblocks

  3. Create an Apilio condition “already_below_threshold” that requires “temp_above_threshold” to be FALSE. Make sure this condition does not trigger logicblocks

Now you can finally do the actions you require

  1. The actions to run when the temperature goes BELOW the threshold. Create an Apilio logicblock “run_when_below_threshold” that does whatever you require (switching on/off a heater/light etc) when triggered by the condition “below_threshold”. However, also require this to depend on the condition “already_above_threshold” so that it only runs if the condition has only just dipped under the threshold temperature. Use the actions to switch on/off your lights/heater etc, but also add a Webhook action that will set your boolean variable “temp_above_threshold” to FALSE.

  2. The actions to run when the temperature goes ABOVE the threshold. Create an Apilio logicblock “run_when_above_threshold” that does whatever you require (switching on/off a heater/light etc) when triggered by the condition “above_threshold”. However, also require this to depend on the condition “already_below_threshold” so that it only runs if the condition has only just gone back over the threshold temperature. Use the actions to switch on/off your lights/heater etc, but also add a Webhook action that will set your boolean variable “temp_above_threshold” to TRUE.

Let us know if this works :slight_smile:

2 Likes

Do you “want” to use the temperature from Weather Underground? If you want the actual outside temperature, it would be great to buy an outdoor temperature sensor that sends the current temperature frequently (I use some from Tuya with Zigbee). Or there are some that send a true/false when a defined threshold is passed.

1 Like

Hi, Thanks for the clear instructions. I have completed stages 1 - 4 and wanted to add a couple of notes about the IFTTT end of things. As of Oct 22, you need a IFTTT PRO PLUS PLAN to access the “query” section

Tap Add query - search for Weather Underground, Select Current Weather and complete the location. Now underneath the trigger are the words “WITH Weather Underground”

I then moved onto the trigger/apilio/update a number variable. That sequence opens this page:

Having selected the number variable that I created earlier, in Apilio I need to tell IFTTT where to get that number from. Click and the screen above arrives. See the drop down I’ve marked? - that gives a choice between Apilio or Weather Underground/Current weather and I was able to select CurrentTempCelsius as required.

SUCCESS - and it’s always good to stop and celebrate before the next challenge

:tropical_drink: Jt

2 Likes

Just looking at this again, it is possible that Apilio is clever enough to avoid repeatedly triggering when you are already above/below the threshold, which would mean that steps 8-10 are not necessary. I suggest trying without steps 8-10 and simplifying your run_when_below_threshold and run_when_above_threshold to only do your main switching actions. It that worked it would certainly be easier!

1 Like

A CONFESSIONS ON VARIABLES - mine did the exact opposite of what I intended :flushed:

Robin has been helping me create a set up (details above) where I can use the outside temperature to trigger my heaters on/off. Having persuaded IFTTT/weather underground to update a number variable called “outside_temp” I need to set up another which creates a threshold. Basically if outside temperatures is over 13 do not turn the heating on. 13 is my threshold.

I was confused for a moment and then interested to create a condition comparing two variables. I’ve only done variables compared to Tuya devices. You see on the right side a second variable has been selected?

This is where it gets embarrassing because I set up my conditions backwards and they did the opposite of what I expected. Turning off when the temperature was below 13!!

So I have hurriedly learned 2 new terms “value” and “reference” to distinguish between two variables in a conditions. The threshold number (my 13) is the value and I needed the reference to be lower to turn on my heating - outside needed to be colder than 13.

This is what the logicblock evaluated when outside was 12 degrees

Below_threshold: true
OK: The value is greater or equal than the reference.

Below 13: true
OK: The threshold temp is greater or equal to outside.

One to remember - value and reference.

1 Like

Have got to number 8 set up - will watch it over the next few days and report if stopping there does the job. I’m hopeful so far :slight_smile: Jt

1 Like

A genuinely interesting thread from your learning @JtGIlbert , thanks!