jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
999 stars 177 forks source link

OutletThermostatDevice - Version 3.4 - how to start to create a new contrib module #206

Open Poil opened 2 years ago

Poil commented 2 years ago

Hi,

I just bought an "ATORCH-Temperature Controller (S1TW)", it's an Outlet and a Thermostat We can use it

    {
        "name": "chauffage bureau",
        "id": "xxxxxxxxxxx",
        "key": "xxxxxxxx",
        "mac": "fc:67:xx:xx:xx:xx",
        "category": "wk",
        "product_name": "ATORCH-Temperature Controller (S1TW)",
        "product_id": "rj84vmyhm0dh0jwy",
        "biz_type": 0,
        "model": "S1TW",
        "sub": false,
        "icon": "https://images.tuyaeu.com/smart/icon/bay1598402984069otRu/16527533308169f70b106.jpg"
    },

Payload, what I can extract :

{'dps': 
{
  '101': 'hot',     # { 'name': 'hot', 'enum': ['socket', 'hot', 'colding'] },
  '102': 206,     # { 'name': 'current_temp', 'decode': int }
  '103': False,  # { 'name': 'power_switch_status', 'decode': bool }
  '104': 0,        # { 'name': 'heating_start_temp', 'decode': int}, 
  '105': 0,         # { 'name': 'cooling_start_temp', 'decode': int}, 
  '106': 210,     # { 'name': 'heating_stop_temp', 'decode': int}, 
  '107': 0,         # { 'name': 'cooling_stop_temp', 'decode': int}, 
  '108': 0,          # { 'name': 'current_intensity', 'decode': int}, 
  '109': 0,          # { 'name': 'current_power', 'decode': int}, 
  '110': 23456,  # { 'name': 'current_voltage', 'decode': int }
  '111': 36,        # { 'name': 'total_kwh', 'decode': int }
  '112': 100,      # { 'name': 'kwh_cost', 'decode': int }
  '113': 2650,    # { 'name': 'over_voltage_limit', 'decode': int }
  '114': 2500,   # { 'name': 'over_intensity_limit', 'decode': int }
  '115': 7000,   # { 'name': 'over_power_limit', 'decode', int }
  '116': False,   # {'name': 'child_lock', 'decode': bool }
  '117': 0,         # {'name': 'temp_calibration', 'decode': int }
  '118': 'c',        # {'name': 'temp_unit', 'enum': ['c', 'f'] }
  '120': 0,  # ? 
  '121': 0,  # ?
  '122': 0, # ?
  '123': 0,  # ?
  '124': 692, # this change but cannot find in app
  '125': 36,    # {'name': 'cost', 'decode': int }
  '126': False, # ? 
  '127': 2 # ?
}
}

Not sure where to start to code, should I fork outlet or thermostat device ? Any help is welcome

Best regards

uzlonewolf commented 2 years ago

As ThermostatDevice has a ton of stuff that this device does not, I would start with OutletDevice and copy/paste from ThermostatDevice as needed.

We should probably make a device template to make things easier...

jasonacox commented 1 year ago

Thanks for the PR @Poil !

TODO: make a device template to make things easier...