MarkBryanMilligan / LanternPowerMonitor

The Lantern Power Monitor is a Raspberry Pi service, Java Web Service, and Android application that allow you to monitor every electrical breaker in your house, regardless of how many panels or breakers you have.
GNU General Public License v3.0
80 stars 26 forks source link

Homeassistant API #38

Open zyphlar opened 1 year ago

zyphlar commented 1 year ago

Being able to send power data to Homeassistant would be pretty cool! Obviously a "would be nice" feature.

https://www.home-assistant.io/blog/2021/08/04/home-energy-management/

LeoLopesLage commented 1 year ago

I think it is possible to get this information via https://lanternpowermonitor.com/console

I know that some integrations in home assistant get their info from a xml.

zyphlar commented 1 year ago

Hitting a button to generate a monthly data dump which you can then download via another button isn't quite the same thing as an API. Technically possible, but I'd feel bad about doing it to @MarkBryanMilligan 's servers without checking especially when the goal would be near-realtime data.

MarkBryanMilligan commented 1 year ago

The hubs already support posting data to an MQTT topic. The problem is that the hubs post the power for every breaker every single second and transforming it from that into something that HomeAssistant can consume will take a little effort. I put it out there about a year ago hoping that an HA superuser would play around with it, but no one has so far. Looking at their sensor model I think it would work better if the primary hub pulled down the aggregated per-minute summary (what the phone apps get) and bundle that up into HA's metered format. It's totally doable, but as someone who doesn't use HomeAssistant, I've been quietly waiting for a HA superuser to speak up and help to tackle the issue.

emersonsc commented 1 year ago

Why no just give the option to set up MQTT natively? (think Tasmota)

hdoedens commented 1 year ago

I am using the Lantern Power monitor with Home Assistant.

Now you can add the sensor as an energy device to the HA energy dashboard.

zyphlar commented 1 year ago

OK it took me some extra doing but here's how I got it more or less working (I think:)

{
  "host": "https://lanternpowermonitor.com/currentmonitor/",
  "auth_code": "your_auth_code_here",
  "hub": 0,
  "debug": false,
  "connect_timeout": 3000,
  "socket_timeout": 5000,
  "needs_calibration": false,
  "mqtt_voltage_calibration_factor": 0.0,
  "mqtt_port_calibration_factor": 1.0,
  "mqtt_frequency": 60,
  "mqtt_broker_url": "tcp://homeassistant.local:1883",
  "mqtt_user_name": "your_lantern_user_here",
  "mqtt_password": "your_password_here"
}
# MQTT
mqtt:
  sensor:
    - name: "Breaker 1"
      unique_id: lantern_breaker_1
      state_topic: "lantern_power_monitor/breaker_power/1-1"
      qos: 2
      unit_of_measurement: "W"
      device_class: energy
      value_template: "{{ value_json.power }}"
    - name: "Breaker 2"
      unique_id: lantern_breaker_2
      state_topic: "lantern_power_monitor/breaker_power/1-2"
      qos: 2
      unit_of_measurement: "W"
      device_class: energy
      value_template: "{{ value_json.power }}"
Rogero54 commented 1 year ago

@zyphlar Thanks for the info, That was all I needed to get the rest of the way to get the data to HA.

zyphlar commented 7 months ago

@MarkBryanMilligan I think this thread is the only place besides the source where mqtt_broker_url etc are mentioned, do you think you could maybe copy paste some of this at the bottom of the readme for future travelers? The setup is pretty sweet when it works. Any future plans for the project?