Open chansearrington opened 4 years ago
@SDNick484 Got the stuff extracted from the rectec app easy enough.
but I'm getting an Error
Error while setting up localtuya platform for switch 10:02:55 PM – Switch (ERROR)
Log Details (ERROR) Logger: homeassistant.components.switch Source: custom_components/localtuya/switch.py:46 Integration: Switch (documentation, issues) First occurred: 10:02:55 PM (1 occurrences) Last logged: 10:02:55 PM
Error while setting up localtuya platform for switch Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/localtuya/switch.py", line 46, in setup_platform import pytuya ModuleNotFoundError: No module named 'pytuya'
Looks like we need to change the line "import pytuya" to "from . import pytuya"
@SDNick484 Ok, looks like it's setup but has a connection error?
Logger: homeassistant.components.switch Source: custom_components/localtuya/switch.py:99 Integration: Switch (documentation, issues) First occurred: 8:43:47 AM (1 occurrences) Last logged: 8:43:47 AM
Error while setting up localtuya platform for switch Traceback (most recent call last): File "/config/custom_components/localtuya/switch.py", line 95, in get_status status = self._device.status() File "/config/custom_components/localtuya/pytuya/init.py", line 259, in status data = self._send_receive(payload) File "/config/custom_components/localtuya/pytuya/init__.py", line 171, in _send_receive data = s.recv(1024) ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/localtuya/switch.py", line 76, in setup_platform config.get(CONF_ID) File "/config/custom_components/localtuya/switch.py", line 129, in init self._status = self._device.status() File "/config/custom_components/localtuya/switch.py", line 113, in status self._cached_status = self.get_status() File "/config/custom_components/localtuya/switch.py", line 99, in get_status raise ConnectionError("Failed to update status.") ConnectionError: Failed to update status.
@SDNick484 I'm not sure if this is the cause of the second error, but I'm currently using the "Packages" concept and Secrets.
So I have CONFIG > packages > rectec.yaml
###################################
# RecTec RT-700 Bull Package
###################################
###################################
# Climate
###################################
###################################
# Sensors
###################################
sensor:
- platform: template
sensors:
rectec_target:
value_template: >-
{{ states.switch.rectec.attributes.target }}
unit_of_measurement: 'F'
rectec_current:
value_template: >-
{{ states.switch.rectec.attributes.current }}
unit_of_measurement: 'F'
rectec_probea:
value_template: >-
{{ states.switch.rectec.attributes.probea }}
unit_of_measurement: 'F'
rectec_probeb:
value_template: >-
{{ states.switch.rectec.attributes.probeb }}
unit_of_measurement: 'F'
###################################
# switch
###################################
switch:
- platform: localtuya
host: !secret rectec_host
local_key: !secret rectec_local_key
device_id: !secret rectec_device_id
name: smoker
And then CONFIG > secrects.yaml
#RecTec
rectec_host: 192.168.1.223
rectec_local_key: 2a3c1a64ff1fca1g
rectec_device_id: 07200374b4e62d1b20dg
@SDNick484 in case it helps, here's my gw_storage.xml contents
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="gw_groupaz154241g45746505CfIZJ7327d83ec3011f6c88581b6bb72d09bf7d">[]</string>
<string name="gw_dev">[{"ability":0,"bv":"5.24","devices":[{"ability":0,"appRnVersion":"1.0","attribute":4,"devId":"07200374b4e62d1b20df","displayDps":"[]","displayMsgs":"{}","dps":{"1":false,"102":230,"103":0,"104":65,"105":183,"106":0,"107":0,"108":false,"109":false,"110":false,"111":false,"112":0,"113":0},"faultDps":[],"i18nTime":1585277377201,"icon":"smart/product_icon/kx.png","iconUrl":"https://images.tuyaus.com/smart/product_icon/kx.png","isOnline":true,"name":"Big Bear's Bull","panelConfig":{"bic":[{"code":"timer","selected":false},{"code":"jump_url","selected":false}]},"productId":"1CwNbNLE8r70WR7t","quickOpDps":"[]","rnFind":false,"schema":"[{\"mode\":\"rw\",\"code\":\"Power\",\"name\":\"电源开关\",\"property\":{\"type\":\"bool\"},\"iconname\":\"icon-dp_power\",\"id\":1,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"rw\",\"code\":\"Set_temp\",\"name\":\"设定温度\",\"property\":{\"unit\":\"\",\"min\":0,\"max\":65535,\"scale\":0,\"step\":5,\"type\":\"value\"},\"id\":102,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"Actual_temp\",\"name\":\"实际温度\",\"property\":{\"unit\":\"\",\"min\":0,\"max\":65535,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":103,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"rw\",\"code\":\"Min_feedrate\",\"name\":\"最小下料量\",\"property\":{\"unit\":\"\",\"min\":0,\"max\":255,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":104,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"Food_temp1\",\"name\":\"食物温度1\",\"property\":{\"unit\":\"\",\"min\":0,\"max\":65535,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":105,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"Food_temp2\",\"name\":\"食物温度2\",\"property\":{\"unit\":\"\",\"min\":0,\"max\":65535,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":106,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"rw\",\"code\":\"Temp_adjust\",\"name\":\"温度校准\",\"property\":{\"unit\":\"\",\"min\":-128,\"max\":127,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":107,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"wr\",\"code\":\"Temp_unit\",\"name\":\"温度单位切换\",\"property\":{\"type\":\"bool\"},\"id\":108,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"ER1\",\"name\":\"ER1报警\",\"property\":{\"type\":\"bool\"},\"id\":109,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"ER2\",\"name\":\"ER2报警\",\"property\":{\"type\":\"bool\"},\"id\":110,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"ER3\",\"name\":\"ER3报警\",\"property\":{\"type\":\"bool\"},\"id\":111,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"wr\",\"code\":\"Food_temp1_threshold\",\"name\":\"Probe A Threshold\",\"property\":{\"unit\":\"\",\"min\":0,\"max\":65535,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":112,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"wr\",\"code\":\"Food_temp2_threshold\",\"name\":\"Probe B Threshold\",\"property\":{\"unit\":\"\",\"min\":0,\"max\":65535,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":113,\"type\":\"obj\",\"desc\":\"\"}]","schemaExt":"[]","supportGroup":true,"switchDp":0,"ui":"0000000167_","uiConfig":{},"uiPhase":"release","uiType":"RN","verSw":"1.0.0"}],"gwId":"07200374b4e62d1b20df","gwType":"s","icon":"smart/product_icon/kx.png","iconUrl":"https://images.tuyaus.com/smart/product_icon/kx.png","isActive":true,"isOnline":true,"isShare":false,"lat":"","localKey":"2a3c1a64ff1fca1g","lon":"","name":"Big Bear's Bull","pv":"2.1","runtimeEnv":"prod","time":1586140387,"updateCacheTime":1586140459924,"uuid":"07200374b4e62d1b20dg","verSw":"2.2.3"}]</string>
</map>
@SDNick484
Cleaned up version:
?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="gw_groupaz154241g45746505CfIZJ7327d83ec3011f6c88581b6bb72d09bf7d">[]</string>
<string name="gw_dev">
[
{
ability:0
bv:5.24,
devices:
[
{
ability:0,
appRnVersion:1.0,
attribute:4,
devId:07200374b4e62d1b20dg,
displayDps:[],
displayMsgs:{},
dps:{1:false,102:230,103:0,104:65,105:183,106:0,107:0,108:false,109:false,110:false,111:false,112:0,113:0},
faultDps:[],
i18nTime:1585277377201,
icon:smart/product_icon/kx.png,
iconUrl:https://images.tuyaus.com/smart/product_icon/kx.png,
isOnline:true,
name:Big Bear's Bull,
panelConfig:{bic:[{code:timer,selected:false},{code:jump_url,selected:false}]},
productId:1CwNbNLE8r70WR7t,
quickOpDps:[],
rnFind:false,
schema:
[
{
mode:rw,
code:Power,
name:电源开关,
property:{type:bool},
iconname:icon-dp_power,
id:1,
type:obj,
desc:
},
{
mode:rw,
code:Set_temp,
name:设定温度,
property:{unit:,min:0,max:65535,scale:0,step:5,type:value},
id:102,
type:obj,
desc:
},
{
mode:ro,
code:Actual_temp,
name:实际温度,
property:{unit:,min:0,max:65535,scale:0,step:1,type:value},
id:103,
type:obj,
desc:
},
{
mode:rw,
code:Min_feedrate,
name:最小下料量,
property:{unit:,min:0,max:255,scale:0,step:1,type:value},
id:104,
type:obj,
desc:
},
{
mode:ro,
code:Food_temp1,
name:食物温度1,
property:{unit:,min:0,max:65535,scale:0,step:1,type:value},
id:105,
type:obj,
desc:
},
{
mode:ro,
code:Food_temp2,
name:食物温度2,
property:{unit:,min:0,max:65535,scale:0,step:1,type:value},
id:106,
type:obj,
desc:
},
{
mode:rw,
code:Temp_adjust,
name:温度校准,
property:{unit:,min:-128,max:127,scale:0,step:1,type:value},
id:107,
type:obj,
desc:
},
{
mode:wr,
code:Temp_unit,
name:温度单位切换,
property:{type:bool},
id:108,
type:obj,
desc:
},
{
mode:ro,
code:ER1,
name:ER1报警,
property:{type:bool},
id:109,
type:obj,
desc:
},
{
mode:ro,
code:ER2,
name:ER2报警,
property:{type:bool},
id:110,
type:obj,
desc:
},
{
mode:ro,
code:ER3,
name:ER3报警,
property:{type:bool},
id:111,
type:obj,
desc:
},
{
mode:wr,
code:Food_temp1_threshold,
name:Probe A Threshold,
property:{unit:,min:0,max:65535,scale:0,step:1,type:value},
id:112,
type:obj,
desc:
},
{
mode:wr,
code:Food_temp2_threshold,
name:Probe B Threshold,
property:{unit:,min:0,max:65535,scale:0,step:1,type:value},
id:113,
type:obj,
desc:
}
],
schemaExt:[],
supportGroup:true,
switchDp:0,
ui:0000000167_,
uiConfig:{},
uiPhase:release,
uiType:RN,
verSw:1.0.0
}
],
gwId:07200374b4e62d1b20dg,
gwType:s,
icon:smart/product_icon/kx.png,
iconUrl:https://images.tuyaus.com/smart/product_icon/kx.png,
isActive:true,
isOnline:true,
isShare:false,
lat:,
localKey:2a3c1a64ff1fca1g,
lon:,
name:Big Bear's Bull,
pv:2.1,
runtimeEnv:prod,
time:1586140387,
updateCacheTime:1586140459924,
uuid:07200374b4e62d1b20dg,
verSw:2.2.3
}
]
</string>
</map>
Installed NodeJS and NPM on ubuntu using: https://linuxize.com/post/how-to-install-node-js-on-ubuntu-18.04/
Installed TuyaCLI using: https://github.com/TuyaAPI/cli
Ran the test command from TuyaCLI to check if ID & Key were working: https://github.com/SDNick484/rectec_status/wiki/Device-ID-&-Key-Extraction
Set succeeded the grill turned on! woohoo!!!
@SDNick484 Not sure what's different, but I used this version of localtuya from @fastcolors instead of the version you pointed me to from @milesperhour and it worked.
No idea why.
https://github.com/fastcolors/localtuya-homeassistant
I'm going to try copying your rt.py over now and see if it still works.
@SDNick484 looks like we need to add a unique id to our config.
I'll take a deeper look after work (at lunch now). I know the device only accepts one connection at a time (part of the reason I want to eventually move to MQTT). With that said, HA constantly reconnect so even if something was connected eventually, it retires.
I'm going to diff my switch.py on Hassio with my copy of it (rt.py in Github).
Looks like the code was more different than I had expected; please try the revision of rt.py I just posted. Also as a heads up, I may switch this off to a separate project when I have time to be more organized.
Glad to hear the tuyapi stuff is working (very handy for debugging, and I may play around with some stuff later to learn Node better).
@SDNick484 Awesome! Looks like I now have the switch and the temp sensors!
Starting to look good.
I can turn it on/off and see the temps.
Looks great! I'm working on getting the grill working with tuyamqtt now that the rewrite of python-tuya is supporting the older firmware.
This is awesome! Following this thread I was able to get my Rec Tec controller added to Home Assistant / Grafana.
I can see all my values and turn my grill on/off. Is there anyway at present to adjust the set temp?
Thanks!
@drjared88 That's great to hear it worked for you. The Raspberry Pi that I was running Hassio off of had an issue with its microsd card so I've been off the platform for the last few months. I went ahead and re-installed Hassio on a new SD card tonight. I plan to take another look and will likely fork the Home Assistant work out to another project GitHub so stay tuned.
It looks to me like I can find suitable uuid and localKey values in a file accessible on a non-rooted Android phone via USB/MTP from my Linux machine. I can find values in Phone/Android/data/com.ym.rectecgrill/cache/1.abj
but when I punch them into the rectec_state.py
script, it's not working for me. Can someone confirm the values in that file match the ones in the gw_storage.xml
file?
Woohoo!!! Turns out I have the newer firmware. It works using the tuya-cli
command in #4. Question now is how to get pytua to use the 3.3 protocol...
d = pytuya.OutletDevice(...)
d.set_version(3.3)
The rectec_state.py script is working for me with that change and the values from the 1.abj file on my non-rooted phone.
Awesome, good debugging @pdugas. I still plan to get back to this, just had some personal stuff come up (although that's now wrapping up). Also dealing with Spare the Air days restricting my grilling due to CA fires.
https://github.com/pdugas/recteq
This is working for me now.
Hey there,
I'm another RecTec lover (Bull) and really excited to come across this and wondering if you're interested in making this work for Home Assistant.
There are a few people over in the community that are looking for this.
I think it could help you achieve: