🏠 Home Assistant — Connection Guide

Real-Time Energy Monitoring & Insights
Power Trace in Home Assistant

Home Assistant can show Power Trace data next to its own devices. There is no dedicated integration yet, but there is a simple path: Power Trace serves the current readings at /live, and Home Assistant reads them with REST sensors. The Power Trace dashboard itself can be embedded in Home Assistant as a page of its own. It all takes one YAML block and a few clicks.

What you need: Power Trace running and collecting data; Home Assistant on the same network (or both on Tailscale); access to configuration.yaml — easiest with the File editor app (Settings → Apps → Install app).

1
🔌 Check that Home Assistant can reach Power Trace

Open this in a browser on the computer you use for Home Assistant:

http://<Power Trace address>:8000/live

You should see JSON text with "online": true and the readings: power, voltage, current, pf, freq_hz, relay.

💡 Note down the IP address of Power Trace — you will need it in the next step. Use the IP, for example 192.168.0.200, rather than a name: not every device knows a name without a dot such as powertrace. On a Raspberry Pi, hostname -I shows the address — take the one from your local network.
2
📝 Add the sensors to configuration.yaml

Open configuration.yaml (in File editor: folder icon → configuration.yaml) and add the block below at the end of the file. If the file already has a rest: section, add the item to it rather than a second section of the same name.

⚠ Replace 192.168.0.200 with the IP address of your Power Trace from step 1. It is highlighted in the block — it is the only thing to change. With someone else’s address the sensors will be “unavailable”.
rest:
  - resource: http://192.168.0.200:8000/live
    scan_interval: 10
    sensor:
      - name: "PowerTrace power"
        value_template: "{{ value_json.power | float(none) }}"
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
      - name: "PowerTrace voltage"
        value_template: "{{ value_json.voltage | float(none) }}"
        unit_of_measurement: "V"
        device_class: voltage
        state_class: measurement
      - name: "PowerTrace current"
        value_template: "{{ value_json.current | float(none) }}"
        unit_of_measurement: "A"
        device_class: current
        state_class: measurement
      - name: "PowerTrace power factor"
        value_template: "{{ value_json.pf | float(none) }}"
        device_class: power_factor
        state_class: measurement
      - name: "PowerTrace frequency"
        value_template: "{{ value_json.freq_hz | float(none) }}"
        unit_of_measurement: "Hz"
        device_class: frequency
        state_class: measurement
    binary_sensor:
      - name: "PowerTrace relay"
        value_template: "{{ (value_json.relay or {}).on | default(false) }}"
        device_class: power
💡 Indentation matters in YAML: two spaces per level, no tabs. After pasting, check that rest: has no indentation and - resource: has exactly two spaces.
3
🔄 Check the configuration and restart
  • Settings → Tools → YAML → Check configuration (or the address /config/tools/yaml). You should see “Configuration will not prevent Home Assistant from starting!”.
  • On the same page click Restart → Restart Home Assistant. It is safe even without the check: with an error in the configuration Home Assistant will not restart and will show the error.
  • Tools → States, type powertrace in the filter.
✅ Six entities should appear: sensor.powertrace_power, _voltage, _current, _power_factor, _frequency and binary_sensor.powertrace_relay — with the same values as the Power Trace dashboard.
4
🖥 Embed the Power Trace dashboard

Standard Home Assistant cards cannot reproduce the Power Trace charts, episodes and analysis, but the dashboard itself can be added as a page of its own:

  1. Settings → Dashboards → Add dashboard (or the address /config/lovelace/dashboards)
  2. Choose Webpage
  3. URL: http://<Power Trace address>:8000/index.html
  4. Title Power Trace, icon mdi:flash; to have it in the side menu, leave showing in the sidebar on
✅ A Power Trace item appears in the Home Assistant side menu with the full dashboard inside.
⚡
If you want energy in the Energy dashboard

/live has no kWh counter, but Home Assistant can work energy out from power:

  1. Settings → Devices & services → Helpers → Create helper → Integral sensor (or the address /config/helpers)
  2. Input sensor sensor.powertrace_power, Integration method — “Trapezoidal rule”, Metric prefix — k, Time unit — “Hours”
  3. The address /config/energy → Electricity grid → Add grid connection → pick the sensor you created

The bars appear after the first full hour ends. In our check one hour came to 92 Wh against 91 in Power Trace; with sharp load changes the difference can be larger. The exact energy is in Power Trace itself.

⚠ If the electricity grid already has another source for the same meter, Home Assistant adds them up and consumption is doubled. Keep one.
🔔
Power outage alerts

The meter is powered from the same mains, so without power it goes silent and the sensors from step 2 become “unknown”. An automation can build on that: power “unknown” for 5 minutes — the power is out; a number is back — the power came back. No need to edit configuration.yaml.

  1. Settings → Automations & scenes → Create automation → Create new automation, then ⋮ → Edit in YAML.
  2. Replace the content with the block below and save.
alias: "Power Trace: power went out / came back"
mode: queued
triggers:
  - trigger: state
    entity_id: sensor.powertrace_power
    to: [unknown, unavailable]
    for: { minutes: 5 }
    id: lost
  - trigger: state
    entity_id: sensor.powertrace_power
    from: [unknown, unavailable]
    id: back
actions:
  - choose:
      - conditions: [{ condition: trigger, id: lost }]
        sequence:
          - action: persistent_notification.create
            data:
              notification_id: powertrace_power
              title: Power Trace
              message: >-
                ⚡ Power went out at {{ as_local(trigger.to_state.last_changed).strftime('%H:%M') }}
                (or the meter dropped off Wi-Fi)
      - conditions:
          - { condition: trigger, id: back }
          - condition: template
            value_template: >-
              {{ (trigger.to_state.last_changed - trigger.from_state.last_changed).total_seconds() >= 300 }}
        sequence:
          - action: persistent_notification.create
            data:
              notification_id: powertrace_power
              title: Power Trace
              message: >-
                ✅ Power came back at {{ as_local(trigger.to_state.last_changed).strftime('%H:%M') }},
                it was out for {{ ((trigger.to_state.last_changed - trigger.from_state.last_changed).total_seconds() / 60) | round(0) | int }} min
📱 This way the messages appear in Home Assistant’s own notifications (the bell). To get them on your phone, install the Home Assistant Companion app and in both places replace persistent_notification.create with notify.mobile_app_<phone_name>, for example notify.mobile_app_pixel_8.
⏱ The sensor turns “unknown” about 2 minutes after the last reading — that is how long Power Trace waits before treating the data as stale. So the “went out” time here is a little later than the real one and the duration shorter: in one of our checks Home Assistant said “out for 8 min” and Power Trace “11 min”. For the exact time and duration use Power Trace’s own notifications.
✅ Checked by switching the relay off at the breaker for 11 minutes: both messages arrived.
🔒
If Home Assistant is opened over https

Then an embedded dashboard with an http:// address does not load: Home Assistant itself says it cannot show an http iframe. You need an https address for Power Trace. The easiest way to get one is Tailscale — for Power Trace, and for Home Assistant too if it has no https yet:

  1. On the Power Trace machine run tailscale serve --bg http://127.0.0.1:8000 (on a Raspberry Pi with sudo), see the Tailscale guide. Power Trace becomes available as https://<name>.<your tailnet>.ts.net.
  2. If Home Assistant has no https yet: Settings → Apps → Install app → Tailscale; in its configuration, under “Share Home Assistant with Serve or Funnel”, choose serve and save. Do not start it yet.
  3. Settings → System → Network → HTTP server → Reverse proxy (or the address /config/network): turn on Trust X-Forwarded-For, add 127.0.0.1 to Trusted proxies, click Save → Save and restart. After the restart, confirm the new settings, or Home Assistant reverts them in a few minutes.
  4. Start the Tailscale app and approve the login at the link in its log. Home Assistant becomes available as https://homeassistant.<your tailnet>.ts.net.
  5. In the Power Trace webpage (step 4) set the URL to https://<Power Trace name>.<your tailnet>.ts.net/index.html.
⚠ The order matters: without step 3 the Tailscale app stops with “Unable to connect to Home Assistant as reverse proxy”. These settings are made in the interface — recent Home Assistant versions ignore an http: block in configuration.yaml. And do not choose funnel: it opens Home Assistant to the internet.
✅ Checked: the Power Trace dashboard works inside Home Assistant opened over https. Both .ts.net addresses open only on devices in your Tailscale network. The REST sensors (step 2) do not depend on this: Home Assistant itself makes the requests to /live, so the http address stays there.
i
Limitations
  • Works within your home network: the device you view Home Assistant on must reach Power Trace. Away from home — only through Tailscale.
  • If Home Assistant is opened over https://, embed Power Trace by its https address — see the section above.
  • The collector updates the readings about once a minute, so there is no point polling more often.
  • When Power Trace is offline, the numeric sensors become “unknown” and the relay state shows “off”.
  • There is no dedicated integration or MQTT with discovery yet.
?
Troubleshooting

Sensors “unavailable”. Most often the block still has the address from the example. Check the address and the network: open /live from the Home Assistant machine. For requests by a public name Power Trace answers 403 — use the IP address, a .local or .lan name, or the Tailscale name.

A message about http instead of the dashboard. Home Assistant is opened over https:// — see the https section.

Configuration error. Most often the YAML indentation or a second rest: section.

Need an MQTT integration with discovery? Write to us — it tells us whether it is worth building.