lux4rd0 / sense-collector

Sense Collector provides a way of collecting real-time data from the Sense Energy Monitor. Includes Grafana dashboards for visualizations of detected devices and smart plugs and their wattage, voltage, and amp utilization.
https://labs.lux4rd0.com/sense-collector/
GNU Affero General Public License v3.0
25 stars 4 forks source link

Live dashboard doesn't match code #9

Closed ElanHasson closed 2 weeks ago

ElanHasson commented 1 year ago

Hi, the live dashboard seems to have different values than the repository used in the dashboard.

I've forked and updated the code to use influx 2.0 api, and got it working.

Any chance you could push the new code and dashboards up to this repo? Thanks!

image

CodaBool commented 1 year ago

nice, your changes worked well. I made a new docker-compose off that still gives some errors but gives enough data for me to be happy.

As a note to anyone reading this assumes having ElanHasson's fork cloned.

version: '3.8'
services:
  sense:
    container_name: sense
    depends_on:
      - influxdb
    build:
      context: ./sense-collector
    environment:
      TZ: America/New_York
      SENSE_COLLECTOR_HOST_HOSTNAME: generated from generate_docker script
      SENSE_COLLECTOR_INFLUXDB_PASSWORD: copied from going to influx ui at localhost:8086
      SENSE_COLLECTOR_INFLUXDB_URL: http://influxdb:8086/write?db=PUT_YOUR_INIT_BUCKET_HERE
      SENSE_COLLECTOR_INFLUXDB_USERNAME: username from influx ui
      SENSE_COLLECTOR_PERF_INTERVAL: 60
      SENSE_COLLECTOR_DISABLE_HEALTH_CHECK: true
      SENSE_COLLECTOR_TOKEN: generated from generate_docker script
      SENSE_COLLECTOR_MONITOR_ID: generated from generate_docker script
    restart: always
  influxdb:
    image: influxdb:latest
    container_name: influxdb
    restart: unless-stopped
    ports:
      - 8086:8086
    volumes:
      - ./config:/etc/influxdb2
      - ./db:/var/lib/influxdb2
ElanHasson commented 1 year ago

@CodaBool What errors are you seeing?

I'm considering rewriting in go as bash scripts aren't my strength.

Hats off to @lux4rd0 for being able to manage large scripts.

CodaBool commented 1 year ago

Not at home right now but I believe it was 404 codes (edit: conn refused)

CodaBool commented 1 year ago

docker logs for sense-collector prints the following line multiple times: curl: (7) Failed to connect to influxdb port 8086: Connection refused But again it pulls a lot of data into influx. So, it's not clear if this is even breaking something.

CodaBool commented 1 year ago

resolved the issue by delaying the startup of sense container. It was trying to connect to the database without it being available yet. You can do this with a healthcheck and depends on docker specs. Here is an example compose file

version: '3.8'
services:
  sense:
    container_name: sense
    depends_on:
      - influxdb
    build:
      context: ./sense-collector
    depends_on:
      - influxdb
    environment:
      TZ: America/New_York
      SENSE_COLLECTOR_HOST_HOSTNAME: # created from `generate_docker-compose.sh`
      SENSE_COLLECTOR_INFLUXDB_PASSWORD: # influx api token (from localhost:8086 ui)
      SENSE_COLLECTOR_INFLUXDB_URL: http://influxdb:8086/write?db=PUT_YOUR_INIT_BUCKET_HERE
      SENSE_COLLECTOR_INFLUXDB_USERNAME: # influx username (from localhost:8086 ui)
      SENSE_COLLECTOR_PERF_INTERVAL: 60
      SENSE_COLLECTOR_DISABLE_HEALTH_CHECK: true
      SENSE_COLLECTOR_TOKEN: # created from `generate_docker-compose.sh`
      SENSE_COLLECTOR_MONITOR_ID: # created from `generate_docker-compose.sh`
    restart: unless-stopped
  influxdb:
    image: influxdb:latest
    container_name: influxdb
    healthcheck:
      test: ["CMD", "curl", "localhost:8086"]
    restart: unless-stopped
    ports:
      - 8086:8086
    volumes:
      - ./config:/etc/influxdb2
      - ./db:/var/lib/influxdb2
ElanHasson commented 1 year ago

ahh, i'm running in kubernetes, so my influx is always on.

everydaylearner commented 11 months ago

@ElanHasson how did you get the grafana graphs working. I have influxdb2 container deployed and deployed new container from your repo. I can see data flowing into influxdb (sense bucket) but i am having hardtime to get grafana graphs working.

Do you know what is the configuration needs to be done on Grafana side?

Thank you!

ElanHasson commented 11 months ago

@everydaylearner I had to modify the scripts to use the new API format. See my fork. https://github.com/ElanHasson/sense-collector

everydaylearner commented 11 months ago

I deployed the container you created but i am not getting any data into grafana some reason, though i can see data is flowing into influxdb2.

Did you need to modify the dashboards? or did you use the original dashboards?

lux4rd0 commented 2 weeks ago

Hey guys, I appreciate your help keeping things alive here! A new version was just released that should be easier to use and run with InfluxDB.