tinytuya icon indicating copy to clipboard operation
tinytuya copied to clipboard

Setting a specific scene on an LED Strip

Open dan00ile opened this issue 11 months ago • 3 comments

Hi. I have an LED lamp running on version 3.5, which has multiple operating modes. As I understand it, DP25 stores information about the current configuration of the enabled scene. I wanted to know how I can read and change this information. Right now, when I request status(), I only get this response: {'dps': {'20': True, '21': 'scene', '24': '002803e803e8', '26': 0, '47': 50, '53': 18, '101': 'RGB'}}. Is there any way to expand the number of dps I get it from?

Sorry for the stupid questions(

"product_name": "Desktop atmosphere light",
        "product_id": "tc96vn32pheav8dg",
        "biz_type": 18,
        "model": "\u9879\u76ee12-PCB_320P1-V1.1",
        "sub": false,
        "icon": "https://images.tuyaeu.com/smart/icon/ay1572836370796htGWH/0c8aa01a17a8f52e0ecfe3d4e6a840f6.png",
        "mapping": {
            "20": {
                "code": "switch_led",
                "type": "Boolean",
                "values": {}
            },
            "21": {
                "code": "work_mode",
                "type": "Enum",
                "values": {
                    "range": [
                        "white",
                        "colour",
                        "scene",
                        "music"
                    ]
                }
            },
            "24": {
                "code": "colour_data",
                "type": "Json",
                "raw_values": "{\"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}}",
                "values": {
                    "h": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 360,
                        "step": 1
                    },
                    "s": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 1000,
                        "step": 1
                    },
                    "v": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 1000,
                        "step": 1
                    }
                }
            },
            "26": {
                "code": "countdown",
                "type": "Integer",
                "values": {
                    "unit": "s",
                    "min": 0,
                    "max": 86400,
                    "scale": 0,
                    "step": 1
                }
            },
            "27": {
                "code": "music_data",
                "type": "Json",
                "raw_values": "{\"change_mode\":{\"range\":[\"direct\",\"gradient\"]}, \"bright\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"temperature\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}",
                "values": {
                    "change_mode": {
                        "range": [
                            "direct",
                            "gradient"
                        ]
                    },
                    "bright": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 1000,
                        "step": 1
                    },
                    "temperature": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 1000,
                        "step": 1
                    },
                    "h": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 360,
                        "step": 1
                    },
                    "s": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 255,
                        "step": 1
                    },
                    "v": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 255,
                        "step": 1
                    }
                }
            },
            "28": {
                "code": "control_data",
                "type": "Json",
                "raw_values": "{\"change_mode\":{\"range\":[\"direct\",\"gradient\"]}, \"bright\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"temperature\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":1000,\"step\":1}, \"h\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":360,\"step\":1},\"s\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1},\"v\":{\"min\":0,\"scale\":0,\"unit\":\"\",\"max\":255,\"step\":1}}",
                "values": {
                    "change_mode": {
                        "range": [
                            "direct",
                            "gradient"
                        ]
                    },
                    "bright": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 1000,
                        "step": 1
                    },
                    "temperature": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 1000,
                        "step": 1
                    },
                    "h": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 360,
                        "step": 1
                    },
                    "s": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 255,
                        "step": 1
                    },
                    "v": {
                        "min": 0,
                        "scale": 0,
                        "unit": "",
                        "max": 255,
                        "step": 1
                    }
                }
            }
        },
        "ip": "192.168.0.149",
        "version": "3.5"

dan00ile avatar Jan 24 '25 21:01 dan00ile

If you start a monitor loop https://github.com/jasonacox/tinytuya/blob/master/examples/monitor.py and change the scene using the SmartLife app, what does it say?

uzlonewolf avatar Jan 24 '25 21:01 uzlonewolf

 > Send Request for Status < 
Initial Status: {'dps': {'20': True, '21': 'scene', '24': '002803e803e8', '26': 0, '47': 50, '53': 18, '101': 'RGB'}}
 > Begin Monitor Loop <
Received Payload: None
Received Payload: None
Received Payload: None
Received Payload: {'protocol': 4, 't': 1737802775, 'data': {'dps': {'51': 'ARcDXl5gAABkADgvAB5cANVFARpk'}}, 'dps': {'51': 'ARcDXl5gAABkADgvAB5cANVFARpk'}}
Received Payload: None
Received Payload: {'protocol': 4, 't': 1737802783, 'data': {'dps': {'51': 'ARYKZGRgAABkAJJfAMZg'}}, 'dps': {'51': 'ARYKZGRgAABkAJJfAMZg'}}
Received Payload: {'protocol': 4, 't': 1737802787, 'data': {'dps': {'51': 'ARkKVFRgAABkALEsAMBk'}}, 'dps': {'51': 'ARkKVFRgAABkALEsAMBk'}}
Received Payload: {'protocol': 4, 't': 1737802790, 'data': {'dps': {'51': 'ARsDX19gAABkAK45AMRdAPlk'}}, 'dps': {'51': 'ARsDX19gAABkAK45AMRdAPlk'}}

dan00ile avatar Jan 25 '25 11:01 dan00ile

Interesting to see payload duplicate the same dps (51):

{
	'dps': {
		'51': 'ARcDXl5gAABkADgvAB5cANVFARpk'
	}
}, 
	'dps': {
		'51': 'ARcDXl5gAABkADgvAB5cANVFARpk'
	}
}

@dan00ile Did you try sending back those values of 51 to see if it replicated what you did in the app?

import tinytuya

d = tinytuya.BulbDevice('DEVICE_ID_HERE', 'IP_ADDRESS_HERE', 'LOCAL_KEY_HERE', version=3.5)
d.set_socketPersistent(True)  

# Set 51
d.set_value(51, 'ARcDXl5gAABkADgvAB5cANVFARpk')

jasonacox avatar Jan 25 '25 16:01 jasonacox