Smart Home smoke detector #87
Replies: 6 comments 8 replies
-
Hi @edgarhildering - Most battery powered Tuya devices do not stay online. They boot up, connect to the WiFi and send their data payloads to the Tuya Cloud, then they shut down to save power. The result means that it is very difficult to get a local connection to these devices to mine that data. If you do manage to ping them enough to catch it when it wakes ups, you may end up keeping it alive but draining the battery. All that to say, you are probably better off getting this data from the Tuya Cloud instead of directly from the device (which TinyTuya provides). I am getting enough interest from the community to add Cloud functions to TinyTuya. It already uses Tuya Cloud for the Wizard so expanding those to accessible functions shouldn't be too hard. Look for an update soon (if my holiday time off goes well :). Feel free to share any tips you have with your TinyTuya + mqtt + Domoticz stack! Others may be appreciate it as well. |
Beta Was this translation helpful? Give feedback.
-
Thanks for yor reply Jason!
Op vr 10 dec. 2021 06:28 schreef Jason Cox ***@***.***>:
… Hi @edgarhildering <https://github.com/edgarhildering> -
Most battery powered Tuya devices do not stay online. They boot up,
connect to the WiFi and send their data payloads to the Tuya Cloud, then
they shut down to save power. The result means that it is very difficult to
get a local connection to these devices to mine that data. If you do manage
to ping them enough to catch it when it wakes ups, you may end up keeping
it alive but draining the battery. All that to say, you are probably better
off getting this data from the Tuya Cloud instead of directly from the
device (which TinyTuya provides).
I am getting enough interest from the community to add Cloud functions to
TinyTuya. It already uses Tuya Cloud for the Wizard so expanding those to
accessible functions shouldn't be too hard. Look for an update soon (if my
holiday time off goes well :).
Feel free to share any tips you have with your TinyTuya + mqtt + Domoticz
stack! Others may be appreciate it as well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#87 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB53ECI2NRLJLDDQVXGEFLLUQGFXRANCNFSM5JWJZQJA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
Hi Jason,
Hope you had a good Christmas overthere. We had some snow (Netherlands and
Germany) but it is thawing away at the moment...
You wrote: "I am getting enough interest from the community to add Cloud
functions to TinyTuya". You may add me for more interest, Among my X-mas
presents were: a Tuya Smart Camera and a Tuya Smoke detector. Of course I
want to connect them to domoticz.
Currently I am writing the 'story' of the connection domoticz <-> MQTT <->
ESP8266-DIY and domoticz <-> MQTT <-> Python <-> TinyTuya <->
Tuya-off-the-shelf. As you can expect "<-> ESP8266-DIY" is actually the
same as "<-> Python <-> TinyTuya <-> Tuya-off-the-shelf". The story is not
complete yet, still working on it.
The wizard is able to 'inspect' the cloud. If I can be of assistance to
help you with testing.
kind regards, --Edgar
…On Fri, Dec 10, 2021 at 7:28 PM Edgar Hildering ***@***.***> wrote:
Thanks for yor reply Jason!
Op vr 10 dec. 2021 06:28 schreef Jason Cox ***@***.***>:
> Hi @edgarhildering <https://github.com/edgarhildering> -
>
> Most battery powered Tuya devices do not stay online. They boot up,
> connect to the WiFi and send their data payloads to the Tuya Cloud, then
> they shut down to save power. The result means that it is very difficult to
> get a local connection to these devices to mine that data. If you do manage
> to ping them enough to catch it when it wakes ups, you may end up keeping
> it alive but draining the battery. All that to say, you are probably better
> off getting this data from the Tuya Cloud instead of directly from the
> device (which TinyTuya provides).
>
> I am getting enough interest from the community to add Cloud functions to
> TinyTuya. It already uses Tuya Cloud for the Wizard so expanding those to
> accessible functions shouldn't be too hard. Look for an update soon (if my
> holiday time off goes well :).
>
> Feel free to share any tips you have with your TinyTuya + mqtt + Domoticz
> stack! Others may be appreciate it as well.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#87 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AB53ECI2NRLJLDDQVXGEFLLUQGFXRANCNFSM5JWJZQJA>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>
|
Beta Was this translation helpful? Give feedback.
-
Hi Jason,
I think I found a little flaw in your code. I got this error just before my
daemon was forced to restart.
Feb 16 12:31:17 ge-domoticz python3.7[13872]: Traceback (most recent call
last):
Feb 16 12:31:17 ge-domoticz python3.7[13872]: File
"/home/pi/domoticz/scripts/python/test11-mqtt.py", line 247, in <module>
Feb 16 12:31:17 ge-domoticz python3.7[13872]:
st=d.set_timer(switches[idx]['dutyTime'])
Feb 16 12:31:17 ge-domoticz python3.7[13872]: File
"/home/pi/.local/lib/python3.7/site-packages/tinytuya/__init__.py", line
1014, in set_timer
Feb 16 12:31:17 ge-domoticz python3.7[13872]: devices = status['dps']
Feb 16 12:31:17 ge-domoticz python3.7[13872]: KeyError: 'dps'
Feb 16 12:31:17 ge-domoticz systemd[1]: tuyaPython.service: Main process
exited, code=exited, status=1/FAILURE
Feb 16 12:31:17 ge-domoticz systemd[1]: tuyaPython.service: Failed with
result 'exit-code'.
Feb 16 12:31:22 ge-domoticz systemd[1]: tuyaPython.service: Service
RestartSec=5s expired, scheduling restart.
Feb 16 12:31:22 ge-domoticz systemd[1]: tuyaPython.service: Scheduled
restart job, restart counter is at 4.
Feb 16 12:31:22 ge-domoticz systemd[1]: Stopped python-process to handle
timed resyncs to domoticz.
Feb 16 12:31:22 ge-domoticz systemd[1]: Started python-process to handle
timed resyncs to domoticz.
When I looked at line 1014 i saw that you try to get a status to find the
dps for the timer. And my conclusion is that the status() did return an
error (905? Offline?) instead of the expected status report that contains
the key dps.
For now I solved the problem by calling the set_timer with parameter 9,
skipping the lines around 1014...
Do what you want with it!
kind regards, --Edgar
…On Fri, Dec 31, 2021 at 10:24 AM Jason Cox ***@***.***> wrote:
Hi @edgarhildering <https://github.com/edgarhildering> - We had a great
Christmas as well! I love the snow... that and a nice warm fire. :)
I have good news. I have just released v1.3.0 that adds Cloud functions to
TinyTuya to make it easier to pull data from the TuyaCloud and manage their
devices via the Cloud APIs. Here is an example script:
import tinytuya
# Turn on Debug Mode (optional)# tinytuya.set_debug(True)
# Connect to Tuya Cloud# c = tinytuya.Cloud() # This uses the tinytuya.json file created by the wizard orc = tinytuya.Cloud(
apiRegion="us",
apiKey="xxxxxxxxxxxxxxxxxxxx",
apiSecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
apiDeviceID="xxxxxxxxxxxxxxxxxxID")
# Display list of devicesdevices = c.getdevices()print("Device List: %r" % devices)
# Select a Device ID to Testid = "xxxxxxxxxxxxxxxxxxID"
# Display Properties of Deviceresult = c.getproperties(id)print("Properties of device:\n", result)
# Display Functions of Deviceresult = c.getfunctions(id)print("Functions of device:\n", result)
# Display DPS IDs of Deviceresult = c.getdps(id)print("DPS IDs of device:\n", result)
# Display Status of Deviceresult = c.getstatus(id)print("Status of device:\n", result)
# Send Command - This example assumes a basic switchcommands = {
'commands': [{
'code': 'switch_1',
'value': True
}, {
'code': 'countdown_1',
'value': 0
}]
}print("Sending command...")result = c.sendcommand(id,commands)print("Results:\n", result)
—
Reply to this email directly, view it on GitHub
<#87 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB53ECKLYVAM76TILREVNKTUTVZFXANCNFSM5JWJZQJA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks for this @edgarhildering. Your workaround is actually the best way to use Bug Fix - I agree with you that throwing a python error when unable to find the DPS value is not what we want. I have added some minor error checking to help with this case. I'll check in the code tonight and it will show up in the v1.3.2 release. |
Beta Was this translation helpful? Give feedback.
-
Some more information
Temperature and infrared sensors are on it's way :P
Don't forget to regenerate it when you add a device.
|
Beta Was this translation helpful? Give feedback.
-
When I read the docs on tinytuya i don't see any docs or examples to connect data-producing devices like thermometers or smoke alarms. I am wondering
I am planning to put smoke alarms in my house and tuya products are a good candidate.
(I am not a great pythoneer, but I managed to combine tinytuya, mqtt and the scheduler in one python script for comms with domoticz through mqtt)
--Edgar
Beta Was this translation helpful? Give feedback.
All reactions