aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: d0a9f96881636b05ae4e24f05783f26c6b5a434d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Energyscripts

This is a small collection of scripts I use to collect information about my
energyconsumption.


## Set up venv

```
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
```


## Handling pip

```
# Create requirements.txt
pip3 freeze > requirements.txt

# Show outdated packages
pip3 list --outdated

# Upgrade package
pip3 install -U name

# Upgrade everything
pip3 install -U -r requirements.txt

# Update requirements.txt
pip3 freeze > requirements.txt
```


## Schema

Install schema
``` 
psql el < schema.sql
```


schema.sql created with:
```
pg_dump --schema-only --no-owner --no-privileges el
```


## Systemd

Example:

```
ln -s /opt/energyscripts/energyscripts-SCRIPT@ADDRESS.service /etc/systemd/system/energyscripts-mqtt_listener.service
ln -s /opt/energyscripts/energyscripts-SCRIPT@ADDRESS.service /etc/systemd/system/energyscripts-esphomeapi@airgradient.local.net.service

systemctl enable energyscripts-mqtt_listener.service energyscripts-esphomeapi@airgradient.local.net.service
systemctl start energyscripts-mqtt_listener.service energyscripts-esphomeapi@airgradient.local.net.service
journalctl -fu "energyscripts-*"

```


## TODO:
Put every state in `states`-table. Entities in an entity-table, and devices in
a device-table.