コード例 #1
0
    def SendStatus(self, location: str, id: str) -> TrailStatus:
        '''
        SendStatus - send trail status directly to a device that requested it. Takes the 
        status and send it on a topic of {self.settings.mqtt_topic}/{location}/{id}

        - location: trail system location (hydrocut)
        - id: client id of the remote device requesting the status (hydrocut_07731)
        '''
        rest = HCStatusREST(self.settings.hcstatus_url)
        status = rest.GetStatus()
        mqttresult = MQTTPublishResponse(clientid=self.settings.mqtt_clientid,
                                         status=status.value,
                                         status_str=status.name,
                                         ok=1)
        topic = f"{self.settings.mqtt_topic_device}/{location}/{id}"
        self.Publish(mqttresult, topic)
        return status
コード例 #2
0
 def test_parsestatus_trail1(self):
     data = {
         "id": "da89b866-ef8d-4853-aab3-7c0f3a1c2fbd",
         "name": "The Hydrocut Trails",
         "status": "open",
         "message": "All trails open!  Enjoy the sunshine before the next rain.",
         "openHashtag": "#trailsopen",
         "closeHashtag": "#trailsclosed",
         "imageUrl": "https://scontent-ort2-1.cdninstagram.com/v/t51.29350-15/182949379_542177793829878_588216878496601361_n.jpg?_nc_cat=105&ccb=1-3&_nc_sid=8ae9d6&_nc_ohc=n5HRbs0klvMAX86Yxwa&_nc_ht=scontent-ort2-1.cdninstagram.com&oh=3869ef7b392ea66bbc9cc6876191d51f&oe=60BB19A8",
         "instagramPostId": "17866670747435204",
         "instagramPermalink": "https://www.instagram.com/p/COibv8-AfZr/",
         "updatedAt": "2021-05-06T16:27:12.803Z",
         "airTemp": 9,
         "groundTemp": 11,
         "trails": [
             {
             "id": "4aec042a-c1bb-4976-a5bf-9abea20fe5d7",
             "name": "Glasgow",
             "closeHashtag": "#glasgowclosed",
             "status": "open",
             "updatedAt": "2021-05-06T16:27:12.834Z"
             },
             {
             "id": "instagram|17841402338843416|default",
             "name": "Snyder's",
             "closeHashtag": "#snydersclosed",
             "status": "closed",
             "updatedAt": "2021-05-05T18:21:12.868Z"
             }
         ],
         "user": {
             "userId": "instagram|17841402338843416",
             "username": "******"
         }
     }        
     rest = HCStatusREST(self.configFile.HCStatusUrl)
     self.assertEqual(rest.ParseStatus(data), TrailStatus.trail1)
コード例 #3
0
 def test_getstatus(self):
     rest = HCStatusREST(self.configFile.HCStatusUrl)
     result = rest.GetStatus()
     # Well, this will only happen if the trails are actually open
     self.assertIsNotNone(result, TrailStatus.open)
コード例 #4
0
 def test_get(self):
     rest = HCStatusREST(self.configFile.HCStatusUrl)
     result = rest.Get()
     self.assertIsNotNone(result)
     self.assertTrue('status' in result)