Tooting daily solar stats to Mastodon

Reading time: 2 minutes (344 words)
Author: @pugmiester
Tags: homeautomation , homeassistant , automation , solar , mastodon , stats

Inspired by a blog post about how to setup Home Assistant to send a daily update for your home solar system stats, I’ve done the same.

I kept telling myself I was just going to look at the options and not do the work because I already have dozens of other things already on my Home Assistant list of things to attack. But, I got side-tracked and “accidentally” finished the setup.

Here’s what I have in my home assistant configuration, in my case in a notify.yaml file, which creates the notification target.

- name: mastodon_solar_bot
  platform: mastodon
  access_token: !secret mastodon_solar_bot_access_token
  client_id: !secret mastodon_solar_bot_client_id
  client_secret: !secret mastodon_solar_bot_client_secret
  base_url: https://botsin.space

I won’t show you the contents of my secrets.yamls file because, well, it’s secret :-)

The automation is pretty simple. It’s set to run 30 minutes after sunset so that it should always have the most up to date information available and I don’t have to manually adjust the times depending on the month of the year. Automation for the win!

I also like to include at least one input_boolean with any automation that generates a notification (either text based or text to speech) so that I have an override in case things go off the rails. Boo for bad automation!

Screenshot of my solar stats to Mastodon automation

And here’s the code that generates the message to be tooted.

service: notify.mastodon_solar_bot
data:
  title: Daily solar stats
  message: >
    The solar forecast for today was {{
    states('input_number.solar_forecast_tomorrow') }}kWh.


    Our solar system generated {{
    states('sensor.givtcp_ed2151g126_pv_energy_today_kwh') }}kWh today.


    We sent {{ states('sensor.home_battery_charge_from_solar') }}kWh to our home
    battery for use when the sun goes down.


    We sent {{ states('sensor.myenergi_zappi_17206758_green_energy_today') }}kWh
    into our EV for some sunny miles


    We exported {{ states('sensor.givtcp_ed2151g126_export_energy_today_kwh')
    }}kWh back to the grid.

My new bot is alive but currently very quiet until I get a few notifications fired off and maybe add some more useful content but if you’re into solar stats you can find the bot here - https://botsin.space/@pugmiestersolar

EDIT: Hmmm, looks like I’m getting the wrong value for the solar forecast into my notification. A challenge for today to figure out.