Jump to content
Posted

Does anyone have any experience or tips for controlling these types of bulbs? There is no bridge so the Hue system doesn't work with them. I have been searching high and low and can only find some IFTTT controls, but I'm not sure how to integrate IFTTT into this addon...

Featured Replies

What about Home Assistant with its LocalTuya integration.

 

  • 5 weeks later...
  • 3 weeks later...
  • Author
On 9/1/2023 at 4:08 PM, DexDeadly said:

@starslayer74what bulbs are they? Maybe we can check for an api on them and go from there. 

They are generic bulbs that use the Tuya/Smart Life app to control (works with Alexa and Google Home)

  • Administrator

Can you set up access to the API, using the instructions from the link you shared?

Step 1: CLIENT_ID and SECRET_KEY

  • Register or Login on Tuya.
  1. Create a cloud development project Cloud -> Project.
  2. After successful creation, you will receive the Client ID and Secret Key.

Step 2: DEVICE_ID

  1. Install Tuya Smart app or Smart Life app on your mobile phone.
  2. Go to Cloud -> Link Devices page.
  3. Selecting a tab Link Devices by App Account.
  4. Click Add App Account and scan the QR code with Tuya Smart app or Smart Life app.
  5. Now you can go to devices Cloud -> Device List and copy Device ID.
    • Notes: Try to select a your region if devices are not displayed.

Step 3: Request access to API calls
Go to Cloud -> API Group and enable Authorization management, Device Management and Device Control.

We can hopefully use the python script if you can get things set up.  The challenge with anything with anything like this is that if I don't have it I can't test it to figure out how to make it work.   The only Tuya thing I have is luckily Hue compatible.

Let me know if you get this set up and I'll suggest your next steps.

  • Author
19 hours ago, Matt said:

Can you set up access to the API, using the instructions from the link you shared?

Step 1: CLIENT_ID and SECRET_KEY

  • Register or Login on Tuya.
  1. Create a cloud development project Cloud -> Project.
  2. After successful creation, you will receive the Client ID and Secret Key.

Step 2: DEVICE_ID

  1. Install Tuya Smart app or Smart Life app on your mobile phone.
  2. Go to Cloud -> Link Devices page.
  3. Selecting a tab Link Devices by App Account.
  4. Click Add App Account and scan the QR code with Tuya Smart app or Smart Life app.
  5. Now you can go to devices Cloud -> Device List and copy Device ID.
    • Notes: Try to select a your region if devices are not displayed.

Step 3: Request access to API calls
Go to Cloud -> API Group and enable Authorization management, Device Management and Device Control.

We can hopefully use the python script if you can get things set up.  The challenge with anything with anything like this is that if I don't have it I can't test it to figure out how to make it work.   The only Tuya thing I have is luckily Hue compatible.

Let me know if you get this set up and I'll suggest your next steps.

I actually did get that part set up, I was playing with Home Assistant like someone suggested, so I do have an API key and Client ID.

 

I experienced some other Home Assistant issues so I don't think I'm going to be using that, but I would love to try out anything else you suggest.

Edited by starslayer74

  • Administrator

Here's my best guess on how to make this work:

  1. Download tuya-bulb-control-main.zip, PreShow.py, and Tuya.pseaction below.
  2. Unzip tuya-bulb-control-main.zip and place it somewhere that your system can access. 
  3. Move PreShow.py to that folder.   
  4. Edit PreShow.py and change the following to the correct details:
    CLIENT_ID = ''
    SECRET_KEY = ''
    DEVICE_ID = ''
    REGION_KEY = ''
  5. Move Tuya.pseaction to the Actions folder in your PreShow Content directory.
  6. Edit "python://path/to/script.py" to the location of PreShow.py.
  7. Test the action.

I don't know if that will work and I can't do anything to test it.  If it does work, it won't do what you want it to do, but that's right now we just want to see if it does anything.  If it works, we can figure out how to make it do what you want afterwards.

Let me know how it goes.

And if there's anyone else with Tuya bulbs, please let us know so that we can get more people to help test.

tuya-bulb-control-main.zip PreShow.py Tuya.pseaction

  • Author
On 10/2/2023 at 4:19 PM, Matt said:

Here's my best guess on how to make this work:

  1. Download tuya-bulb-control-main.zip, PreShow.py, and Tuya.pseaction below.
  2. Unzip tuya-bulb-control-main.zip and place it somewhere that your system can access. 
  3. Move PreShow.py to that folder.   
  4. Edit PreShow.py and change the following to the correct details:
    CLIENT_ID = ''
    SECRET_KEY = ''
    DEVICE_ID = ''
    REGION_KEY = ''
  5. Move Tuya.pseaction to the Actions folder in your PreShow Content directory.
  6. Edit "python://path/to/script.py" to the location of PreShow.py.
  7. Test the action.

I don't know if that will work and I can't do anything to test it.  If it does work, it won't do what you want it to do, but that's right now we just want to see if it does anything.  If it works, we can figure out how to make it do what you want afterwards.

Let me know how it goes.

And if there's anyone else with Tuya bulbs, please let us know so that we can get more people to help test.

tuya-bulb-control-main.zip 9.74 kB · 0 downloads PreShow.py 391 B · 0 downloads Tuya.pseaction 26 B · 0 downloads

I just gave it a go, ran into a few issues:

 

1. I'm not sure what to put in for Region Key

Here is a screenshot of the error I got:

image.thumb.png.f36930c560cb5e634cea582cbb2d58f8.png

 

  • Administrator

@starslayer74The PreShow code to launch the python file didn't work and needed to be modified.  I fixed that, but then I realized the Tuya code from the other site won't work as is.

What do you normally use to control your Tuya bulbs?

  • Author
1 hour ago, Matt said:

@starslayer74The PreShow code to launch the python file didn't work and needed to be modified.  I fixed that, but then I realized the Tuya code from the other site won't work as is.

What do you normally use to control your Tuya bulbs?

Mostly I use Alexa but it's connected through the Tuya Smart Life app.

  • Administrator

I don't have any easy ideas.  I'll look into it further and see if I can come up with something.

  • 2 weeks later...
  • Author
On 10/13/2023 at 10:26 AM, Matt said:

I don't have any easy ideas.  I'll look into it further and see if I can come up with something.

Assuming I could get the lights to talk to Home Assistant, is there a way to trigger it using HA commands in Preshow Experience?

10 hours ago, starslayer74 said:

Assuming I could get the lights to talk to Home Assistant, is there a way to trigger it using HA commands in Preshow Experience?

Yes easy done. I run my lifx beam though HA triggered by Preshow. Get it working in HA and I can help with the rest.

Edited by Johno

  • Author
12 hours ago, Johno said:

Yes easy done. I run my lifx beam though HA triggered by Preshow. Get it working in HA and I can help with the rest.

I really appreciate that. I'm going to build a little HA server on an old Raspberry PI and I'll report back when I have it up and running.

 

Thank you for the assistance!

  • Author
18 hours ago, Johno said:

No problems.

Ok, I have it up and running. I can turn the bulbs on and off, and change colors/brightness in the Home Assistant dashboard.... I am clay in your hands 🙂

On 10/29/2023 at 1:17 PM, starslayer74 said:

Ok, I have it up and running. I can turn the bulbs on and off, and change colors/brightness in the Home Assistant dashboard.... I am clay in your hands 🙂

STEP 1

You have to create a script first, I'll guide you though a simple script to turn on a light, to do this:

Goto Settings - Automations & Scenes - Scripts (from the tabs menu on the page)

1. Press the "+ ADD SCRIPT" button on the bottom right of the page.
2. Select "Create new Script"
3. Name your script eg: "Turn_on_Cinema_Light"  No spaces and give it a icon if you like.
4. Press "+ ADD ACTION" from the drop down select "Call a service"
5. From the Service drop down select "Light: Turn on" and select "Choose device" and select your light you want to turn on. you can also select brightness and color if you like.
6. Press Save
7. To test the script, from the Traces menu (right top side with 3 dots), select run script, the light should turn on.

Edited by Johno

STEP 2 - Create a Long-lived access tokens

1. Select "Profile" menu from the side menu, its the last one on the bottom under Notifications.
2. Scroll to the "Long-lived access tokens" section
3. Press "CREATE TOKEN" Give it a name eg: "Cinema" doesn't really matter what you call it.
4. Make sure to copy the code and save it, as you wont be able to see it again, the token will be about 180 chars long.

Edited by Johno

STEP 3

Create a action script to use with PreShow.

Change the ** ** to suit.

http://**YOUR HA IP ADDRESS**:8123/api/services/script/turn_on
HEADERS: {"Authorization": "Bearer **PASTE YOUR LONG-LIVED ACCESS TOKEN HERE**", "Content-Type": "application/json"}
POST: {"entity_id": "**YOU SCRIPT NAME  eg script.Turn_on_Cinema_Light **"}


Sample attached.

Let me know if you run into any problems and I will create a pdf guide with screen shots etc.

HA is fantastic to what you can do with it example: If someone presses my door bell camera and I am in my home cinema, I have a automation script that will pause the movie playing and display a popup message, saying someones at the front door and also shows the camera video feed. Once you start theirs no going back 🙂.

Movie_Pause.cvaction

Edited by Johno

  • Author
11 hours ago, Johno said:

STEP 3

Create a action script to use with PreShow.

Change the ** ** to suit.

http://**YOUR HA IP ADDRESS**:8123/api/services/script/turn_on
HEADERS: {"Authorization": "Bearer **PASTE YOUR LONG-LIVED ACCESS TOKEN HERE**", "Content-Type": "application/json"}
POST: {"entity_id": "**YOU SCRIPT NAME  eg script.Turn_on_Cinema_Light **"}


Sample attached.

Let me know if you run into any problems and I will create a pdf guide with screen shots etc.

HA is fantastic to what you can do with it example: If someone presses my door bell camera and I am in my home cinema, I have a automation script that will pause the movie playing and display a popup message, saying someones at the front door and also shows the camera video feed. Once you start theirs no going back 🙂.

Movie_Pause.cvaction 368 B · 3 downloads

This helped immensely! I appreciate the assistance, I've got it up and running and yes, now I've got some other ideas too 🙂

Create an account or sign in to comment

Topics