import lacrosse
#Get the latest temperature value from a device named 'temperature'
# First setup your La Crosse View app
email = '{{EMAIL}}'
password = '{{PASSWORD}}'
print("Logging in...")
token = lacrosse.lacrosse_login(email, password)
print("Getting locations...")
locations = lacrosse.lacrosse_get_locations(token)
print("Getting devices...")
devices = lacrosse.lacrosse_get_devices(token, locations)
print(devices)
# for device in devices:
# if device['device_name'] == 'temperature':
# weather_data = lacrosse.lacrosse_get_weather_data(token, device)
# print("Current temperature is: {} {}".format(weather_data['Temperature']['values'][-1]['s'], weather_data['Temperature']['unit']))
Full Code
import lacrosse
import time
import os
import sys
import re
from paho.mqtt import client as mqtt_client
##Log in Information for Lacrosse
email = '{{YOUR EMAIL}}'
password = '{{YOUR PASSWORD}}'
##Configure MQTT Client
broker="{{MQTT BROKER}}"
port=1883
mqtt_user = "{{MQTT USER}}"
mqtt_pass = "{{MQTT PASSWORD}}"
client_id = "WeatherStation"
topic = "homeassistant/sensor"
sub = "lacrosse"
def connect_mqtt():
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to MQTT Broker!")
else:
print("Failed to connect, return code %d\n", rc)
# Set Connecting Client ID
client = mqtt_client.Client(client_id)
client.username_pw_set(mqtt_user, mqtt_pass)
client.on_connect = on_connect
client.connect(broker, port)
return client
# Get the latest temperature value from a device named 'temperature'
# First setup your La Crosse View app
def publish(client,name,finaluom,data):
time.sleep(1)
topicpart = name.replace(" ","_")
fulltopic = topic + "/lacrosse_" + topicpart
statetopic = fulltopic + "/state"
data = float(data)
#print(fulltopic)
#Initialize
config = fulltopic + "/" + "config"
##convert UOM to Match Home Assistant
if finaluom == "degrees_fahrenheit":
finaluom = "°F"
if finaluom == "relative_humidity":
finaluom = "%"
if finaluom == "degrees_celsius":
data = (data * 9/5) + 32
finaluom = "°F"
if finaluom == "kilometers_per_hour":
data = (data * .621371)
finaluom = "mph"
configdata = '{"name": "' + name + '","state_topic": "' + statetopic + '", "unit_of_measurement": "' + finaluom + '", "value_template": "{{value_json}}"}'
result = client.publish(config, configdata)
result = client.publish(statetopic, data)
# result: [0, 1]
status = result[0]
#if status == 0:
#print(f"Send `{data}` to topic `{statetopic}`")
#else:
#print(f"Failed to send message to topic {topic}")
#print("Logging in...")
token = lacrosse.lacrosse_login(email, password)
#print("Getting locations...")
locations = lacrosse.lacrosse_get_locations(token)
#print("Getting devices...")
devices = lacrosse.lacrosse_get_devices(token, locations)
#print(devices)
client = connect_mqtt()
for device in devices:
StationDevices = device['sensor_field_names']
weather_data = lacrosse.lacrosse_get_weather_data(token, device)
#print(weather_data)
for sensors in StationDevices:
if device['sensor_type_name'] == 'Weather Station Display':
temp = "Display" + str(locals()['sensors'])
if device['sensor_type_name'] == 'LTV-WSDTH04':
temp = "Station" + str(locals()['sensors'])
if device['sensor_type_name'] == 'Rain 2.0 Sensor':
temp = str(locals()['sensors'])
value = weather_data[locals()['sensors']]['values'][-1]['s']
value = float(value)
uom = weather_data[locals()['sensors']]['unit']
#exec("%s = %d" % (temp,value))
label = re.sub(r'((?<=[a-z])[A-Z]|(?<!\A)[A-Z](?=[a-z]))', r' \1', temp)
publish(client,label,uom,value)
Direct Links in Video ESPresense Home Page – https://espresense.com/ ESPresense Project Page – https://github.com/ESPresense/ESPresense/ Install Page – https://espresense.com/install Web Terminal – https://espresense.com/terminal Hardware ESP32 “Base Stations” – https://espresense.com/hardware Compatible BLE Trackers – https://espresense.com/beacons Create a Virtual Device Tracker with ESPresense Now if you want to be able to use the ESPresense device as a device…
Table of Contents Summary In this video, we introduce and review the Enbrighten permanent holiday lights. We explain why August is the perfect time to install holiday lights, highlighting the convenience of getting them up before the cold weather sets in. We cover the features of the Enbrighten lights, including RGB and white LEDs, support…
Favorite HACS Components In my video, I mentioned that I have a number of favorite HACS integrations and Lovelace UI elements. All of these elements are available in the HACS store. NWS Alerts https://github.com/finity69x2/nws_alerts I mentioned this in my Severe Weather alerts video. This is the central component that pulls down alerts from the National…
Table of Contents ►Description Want to take your Home Assistant to the next level? In this tutorial, I’ll walk you through setting up HACS 2.0 (Home Assistant Community Store)—the best way to install custom integrations, themes, and frontend plugins for your smart home. HACS 2.0 brings a new UI, faster downloads, and seamless updates, making…
Video EMBED Post Severe weather can strike at any time, and having your smart home warn you the moment an alert is issued can make all the difference. With the updated NWS Alerts integration for Home Assistant, you can get real-time notifications, trigger automations, and display alerts directly on your dashboards. In this guide, I’ll…
Kit with all products needed Links to all source material Original Post from HackaDay user Jon – https://tshouse.link/wifibusy Links to 3D Printable Enclosure https://www.thingiverse.com/thing:4700820 Wiring Diagram for Both ESP8266 / ESP32 https://miro.com/app/board/uXjVOQGQYtQ=/?invite_link_id=343682117250 Preview of Software for Part 2 Information on the ESPHome Project: https://esphome.io/ ESPHome Code Example (ESP32)