Blockly script for switching off Yeelight with 433 remote

Moderator: leecollings

Post Reply
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Blockly script for switching off Yeelight with 433 remote

Post by gschmidt »

Hi,

I wondered if I could make a blockly script which turns of a Yeelight LED Bulb lamp with a 433mhz remote button.

First I learned the 433 mhz remote button in the switches page, and it created a on\off switch automatically.
I called the switch "Yeelights AB", and turning the switch on and off with the remote button is working.

I also have a Yeelight LED Bulb RGBWW wifi lamp.
For this lamp I have created a light/switch, selector switch, dimmer (Hoek Lamp 1) with a virtual switch.
With a dzVents script I control this lamp. Also working (see code below)

Code: Select all

return {
    active = true,
    on = { 
        devices = { 'Hoek Lamp 1'}
    },
    execute = function(domoticz, device)
        port = '55443'
        yeelights = {'192.168.1.57'}
        for ix, ipadress in ipairs(yeelights) do
            if (device.state == 'Off') then
                domoticz.log('Turning light off')
                runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
                os.execute(runcommand)
            else
                domoticz.log('Changing brightness level')
                brightvalue = (device.level - 1);
                runcommand = "sudo echo -ne '{\"id\":1, \"method\":\"set_scene\",\"params\":[\"ct\",2950, " .. brightvalue .. "]}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
                os.execute(runcommand)
            end
        end
    end
}
Next step I created a Blockly script (see attachment), but the Yeelight is not responding when the On/Off Switch is turned on or off...
What am I missing here?

Greetzzz,

Gerben
Attachments
Blockly.JPG
Blockly.JPG (32.35 KiB) Viewed 755 times
welby
Posts: 36
Joined: Monday 20 November 2017 3:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Australia
Contact:

Re: Blockly script for switching off Yeelight with 433 remote

Post by welby »

Do you have it set to activate from a device on the right hand side?
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly script for switching off Yeelight with 433 remote

Post by gschmidt »

Sorry I am not experienced yet in domoticz, what do you mean with "from a device on the right hand side"?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly script for switching off Yeelight with 433 remote

Post by waaren »

Depending on your domoticz version but in latest Beta and versions from before 10 weeks ago you can choose how Blockly scripts are to be triggered.
Either by Time, Device, Security, User variable or All. For this Blockly the logical choose would be Device.

What complicates the answer that this option was removed when the new event editor became active in beta's somewhere in november 2018 and the option came back in Version: 4.10341
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly script for switching off Yeelight with 433 remote

Post by gschmidt »

I have beta version 4.10304
But in my UI in the events manager only the lua and dzVents script have those options.
For the Yeelights dzVents scripts i created, I also did select Device.
Can you maybe upload a screenshot where i can select "Device" when creating a blockly script?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly script for switching off Yeelight with 433 remote

Post by waaren »

Sure I am on V4.10343
Including trigger selector
Including trigger selector
blockly.png (59.99 KiB) Viewed 725 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly script for switching off Yeelight with 433 remote

Post by gschmidt »

Ok , I have the same UI.
Suddenly it is working... :o
No idea why it first did'nt

Thanx for helping anyway
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest