Templates for a few companies. SPS notes.
This commit is contained in:
@ -3,6 +3,7 @@ import json
|
||||
import Apikeys
|
||||
|
||||
|
||||
|
||||
def get_course():
|
||||
count = 0
|
||||
apiKey = Apikeys.walmartprod
|
||||
@ -30,7 +31,6 @@ def get_course():
|
||||
|
||||
if "next" not in nextlink:
|
||||
break
|
||||
|
||||
print(live_courses)
|
||||
|
||||
|
||||
|
||||
BIN
Scripts/Backup/Customer Feedback
Normal file
BIN
Scripts/Backup/Customer Feedback
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
65
Scripts/drac_test.py
Normal file
65
Scripts/drac_test.py
Normal file
@ -0,0 +1,65 @@
|
||||
import adbase
|
||||
import json
|
||||
import time
|
||||
import requests
|
||||
|
||||
|
||||
class birdnet(adbase.ADBase):
|
||||
def initialize(self):
|
||||
self.hassapi = self.get_plugin_api("HASS")
|
||||
self.adapi = self.get_ad_api()
|
||||
self.mqttapi = self.get_plugin_api("MQTT")
|
||||
self.birdnet_mqtt = "birdnet"
|
||||
self.mqttapi.listen_event(
|
||||
self.birdnet_message, "MQTT_MESSAGE", topic=self.birdnet_mqtt
|
||||
)
|
||||
|
||||
def birdnet_message(self, event_name, data, kwargs):
|
||||
pre_split = data["payload"]
|
||||
|
||||
common_name = pre_split.split(",")[0].strip()
|
||||
science_name = pre_split.split(",")[1].strip()
|
||||
date_seen = pre_split.split(",")[2].strip
|
||||
time_seen = pre_split.split(",")[3].strip()
|
||||
confidence = pre_split.split(",")[5].strip()
|
||||
|
||||
# print(f"A {common_name} was seen on {date_seen} at {time_seen}. Confidence is {confidence}.")
|
||||
|
||||
self.mqttapi.mqtt_publish("birdnet/sensors/common_name", common_name)
|
||||
self.mqttapi.mqtt_publish("birdnet/sensors/science_name", science_name)
|
||||
self.mqttapi.mqtt_publish("birdnet/sensors/time_seen", time_seen)
|
||||
self.mqttapi.mqtt_publish("birdnet/sensors/date_seen", date_seen)
|
||||
self.mqttapi.mqtt_publish("birdnet/sensors/confidence", confidence)
|
||||
|
||||
url = f"https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles={science_name}"
|
||||
response = requests.get(url)
|
||||
response = response.json()
|
||||
|
||||
for value in response["query"]["pages"]:
|
||||
wiki_desc = response["query"]["pages"][value]["extract"]
|
||||
self.hassapi.set_state(
|
||||
"sensor.birdnet_wiki", state="on", attributes={"description": wiki_desc}
|
||||
)
|
||||
|
||||
headers = {"User-Agent": "Python_Flickr/1.0"}
|
||||
flickr_api = "2b550e7db4a944843a46e57c263582e3"
|
||||
flickr_url = f"https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key={flickr_api}&text={common_name} bird&sort=relevance&per_page=5&media=photos&format=json&nojsoncallback=1"
|
||||
flickr_resp = requests.get(url=flickr_url, headers=headers)
|
||||
data = flickr_resp.json()["photos"]["photo"][0]
|
||||
print(data)
|
||||
|
||||
image_url = (
|
||||
"https://farm"
|
||||
+ str(data["farm"])
|
||||
+ ".static.flickr.com/"
|
||||
+ str(data["server"])
|
||||
+ "/"
|
||||
+ str(data["id"])
|
||||
+ "_"
|
||||
+ str(data["secret"])
|
||||
+ "_n.jpg"
|
||||
)
|
||||
|
||||
self.hassapi.set_state(
|
||||
"sensor.birdpic_test", state="on", attributes={"image": image_url}
|
||||
)
|
||||
Reference in New Issue
Block a user