Package: wirelesstagpy
WirelessSensorTagsA simple python wrapper library for Wireless Sensor Tag platform (http://wirelesstag.net).Supports getting data for registered by end user sensor tags.
wirelesstag.net account credentials are needed to use this lib.
Enabling tags sharing is not required.Verified with:13-bit motion/temperature/humidity tags (type 13)Water/Moisture tags (type 32)ALS Pro tag (type 26)PIR Kumo sensor (type 72)Installationpip3installwirelesstagpyDevelopment notesSeeapidoc.htmlfor API details.UsageFetch all tagsimportwirelesstagpyapi=wirelesstagpy.WirelessTags(username='login_email',password='your_password')tags=api.load_tags()for(uuid,tag)intags.items():print('Loaded tag:{}, temp:{}, humidity:{}probe taken:{}'.format(tag.name,tag.temperature,tag.humidity,tag.time_since_last_update))Install custom push notificationsWireless Sensor Tags platforms allows to setup custom url calls for set of specific events.importwirelesstagpyapi=wirelesstagpy.WirelessTags(username='login_email',password='your_password')notifications=[NotificationConfig('update',{'url':'http://some_local_ip/update_tags','verb':'POST''disabled':False,'nat':True})]# install notification for tag with id=1 only# use it you have only one tag managersucceed=api.install_push_notification(1,notifications,False)# if you have multiple tag managers you need specify its 'mac' stored in each tag as followingsucceed=api.install_push_notification(sensor.tag_id,notifications,False,sensor.tag_manager_mac)Monitor push events from cloudWireless Sensor Tags platform allows to monitor state of sensors with push notification on change right from cloud.importwirelesstagspyapi=wirelesstagpy.WirelessTags(username='login_email',password='your_password')defcallback(tags_spec,events_spec):for(uuid,tag)intags_spec.items():ifuuidinevents_spec:events=events_spec[uuid]print("triggered events:{}".format(events))print("updated tag:{}".format(tag))# starts long running thread with getting updates from cloud immidiately when change happens.# it is not a polling, but rather a similar to WebSockets get update logicapi.start_monitoring(callback)Arm/Disarm sensor monitoring for specific eventSupported events include: motion, temperature, humidity, lightimportwirelesstagpyapi=wirelesstagpy.WirelessTags(username='login_email',password='your_password')# arm humidity monitoring for tag with id 1,# returned instance is updated SensorTagsensor=api.arm_humidity(1)# Disarm itsensor=api.disarm_humidity(1)# Specify tag manager if you have multiple tag managerssensor=api.arm_humidity(sensor.tag_id,sensor.tag_manager_mac)Working with sensors and binary eventsSingle tag holds notion of multiple sensors and binary events.
Each sensor is entity representing single sensing metric such as temperature, humidity, moisture, light or motion.
You can get list of supported sensors and binary events by callingtag.allowed_sensor_typesfor sensors,tag.supported_binary_events_typesfor binary events.
Also you can query tag on list of supported monitoring conditions that can be represented as switches to be armed/disarmed by callingtag.allowed_monitoring_types.Handling sensors:importwirelesstagpyimportwirelesstagpy.constantsasCONSTapi=wirelesstagpy.WirelessTags(username='login_email',password='your_password')tags=api.load_tags()# get temperature sensor value for tagfor(uuid,tag)intags.items():sensor=tag.sensor[CONST.SENSOR_TEMPERATURE]ifsensorisnotNone:print('{}temperature:{}'.format(tag.name,sensor.value))Handling binary events:importwirelesstagpyimportwirelesstagpy.constantsasCONSTapi=wirelesstagpy.WirelessTags(username='login_email',password='your_password')tags=api.load_tags()# get motion binary event state for each tagfor(uuid,tag)intags.items():ifCONST.EVENT_MOTIONintag.supported_binary_events_types:event=tag.event[CONST.EVENT_MOTION]print('tag{}event state:{}'.format(tag.name,event.is_state_on))Use binary events to build custom push notifications configurationsimportwirelesstagpyimportwirelesstagpy.constantsasCONSTapi=wirelesstagpy.WirelessTags(username='login_email',password='your_password')tags=api.load_tags()tag=tags['uuid-of-tag-in-question']event=tag.event[CONST.EVENT_MOISTURE]ifeventisnotNone:configs=event.build_notifications('http://path_to_post',tag.tag_manager_mac)# install it for any tags of tag managersucceed=api.install_push_notification(0,configs,True,tag.tag_manager_mac)Disclaimer"Wireless Sensor Tags", "KumoSensor" and "Kumostat" are trademarks of Cao Gadgets LLC,
seewww.wirelesstag.netfor more information.I am in no way affiliated with Cao Gadgets LLC.CopyrightSeeLICENSE