Problem w uruchomieniem supla-device na RPI

[email protected]
Posts: 12
Joined: Mon Apr 03, 2023 6:47 pm

Post

Hejo

Próbowałem uruchomić supla-device-linux na raspberryPI wg instrukcji z tego posta:

viewtopic.php?t=10735
ale dostaje wciąż komunikat:

Code: Select all

ERR[0.1680547348] Config file YAML error: bad file
INFO[0.1680547348]  *** Starting supla-device ***
INFO[0.1680547348] Using config file etc/supla-device.yaml
ERR[0.1680547348] Config: "channels" section missing in file
ERR[0.1680547348] Loading channels failed. Exit
mam wgrany plik supla-device.yaml do katalogu etc/ na RPI
mam umieszczony plik last_state.txt w /var/local/supla-device zgodnie z state_files_path w pliku etc/supla-device.yaml
plik supla-device.yaml ma sekcję channels

supa-device.yaml

Code: Select all

# Example supla-device config file for Linux device
# https://github.com/SUPLA/supla-device

name: My fancy device
log_level: debug
state_files_path: "/var/local/supla-device"
security_level: 2 # disable certyficate verification

supla:
  server: svr123.supla.org
  mail: [email protected]

channels:
  - type: VirtualRelay
    name: vr1 # optional, can be used as reference for adding actions (TBD)

  - type: VirtualRelay
    name: vr2

  - type: Fronius
    ip: 192.168.1.7
    port: 80
    device_id: 1

  - type: ThermometerParsed
    name: t1
    temperature: 0
    multiplier: 1
    parser:
      name: parser_1
      type: Simple
      refresh_time_ms: 200
    source:
      name: s1
      type: File
      file: temp.txt

  - type: ThermometerParsed
    name: t2
    temperature: 3
    multiplier: 1
    parser:
      use: parser_1

  - type: ImpulseCounterParsed
    name: i1
    counter: total_m3
    multiplier: 1000
    source:
      type: File
      file: "/var/log/wmbusmeters/meter_readings/water.json"
    parser:
      type: Json

  - type: ElectricityMeterParsed
    parser:
      type: Json
    source:
      type: File
      file: tauron.json
    phase_1:
      - voltage: voltage_at_phase_1_v
        multiplier: 1
      - fwd_act_energy: total_energy_consumption_tariff_1_kwh
        multiplier: 1
      - rvr_act_energy: total_energy_production_tariff_1_kwh
        multiplier: 1
      - power_active: current_power_consumption_kw
        multiplier: 1000
      - rvr_power_active: current_power_production_kw
        multiplier: 1000
    phase_2:
      - voltage: voltage_at_phase_2_v
        multiplier: 1
      - fwd_act_energy: total_energy_consumption_tariff_2_kwh
        multiplier: 1
      - rvr_act_energy: total_energy_production_tariff_2_kwh
        multiplier: 1
    phase_3:
      - voltage: voltage_at_phase_3_v
        multiplier: 1

  - type: ThermometerParsed
    temperature: 0
    source:
      type: Cmd
# call sensors, take line with word "temp3", split it on ":" and return second
# value
      command: "sensors | grep temp3 | cut -d : -f2"
    parser:
      type: Simple

  - type: BinaryParsed
    state: 1
    parser:
      use: parser_1

Dzięki z góry za pomoc
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

[email protected] wrote: Mon Apr 03, 2023 7:09 pm

Code: Select all

INFO[0.1680547348] Using config file etc/supla-device.yaml
mam wgrany plik supla-device.yaml do katalogu etc/ na RPI
Pewnie masz konfigurację w /etc/supla-device.yaml, a uruchamiasz binarkę z jakiegoś innego katalogu niż /.
Uruchom z polecenia:
./supla-device -c /etc/supla-device.yaml
Najlepsze suple dla Twojego domu :mrgreen:
[email protected]
Posts: 12
Joined: Mon Apr 03, 2023 6:47 pm

Post

Hej Dzięki :)

Tak dokładnie było. Wczoraj się kapnąłem i uruchamiam z opcją "-c"
[email protected]
Posts: 12
Joined: Mon Apr 03, 2023 6:47 pm

Post

Męczę się jeszcze z dwoma sprawami

1) sprawa:

czy mam poprawny plik .json dla:
channel -> ElectricityMeterParsed

oto plik json

Code: Select all

{
    "phase_1": [
      {
        "voltage": "250.01",
        "multiplier": 1
      },
      {
        "fwd_act_energy": "11.0",
        "multiplier": 1
      },
      {
        "rvr_act_energy": "11.0",
        "multiplier": 1
      },
      {
        "power_active": "11.0",
        "multiplier": 1000
      },
      {
        "rvr_power_active": "11.0",
        "multiplier": 1000
      }
    ],
    "phase_2": [
      {
        "voltage": "250.01",
        "multiplier": 1
      },
      {
        "fwd_act_energy": "11.0",
        "multiplier": 1
      },
      {
        "rvr_act_energy": "11.0",
        "multiplier": 1
      }
    ],
    "phase_3": [
      {
        "voltage": "250.01",
        "multiplier": 1
      }
    ]
  }
2) sprawa:
w logach po uruchomieniu apki mam to:

Code: Select all

INFO[0.1680610333] Connected to Supla Server
INFO[0.1680610333] LAST STATE ADDED: Register in progress
INFO[0.1680610333] Current status: [10] Register in progress
INFO[0.1680610335] LAST STATE ADDED: Bad credentials - incorrect AuthKey or email
INFO[0.1680610335] Current status: [25] Bad credentials - incorrect AuthKey or email
dlaczego jest: Current status: [25] Bad credentials - incorrect AuthKey or email
skoro jest wcześniej Connected to Supla Server

gdzie robię błąd?

w ustawieniach supla-device.yaml mam to:

Code: Select all

name: My fancy device
log_level: debug
state_files_path: "/var/local/supla-device"
security_level: 2 # disable certyficate verification

supla:
  server: svr12.supla.org
  mail: [email protected]
a tutaj cały log:

Code: Select all

pi@raspberrypi:~ $ sudo ./supla-device/extras/examples/linux/build/supla-device-linux -c /home/pi/supla-device/extras/examples/linux/supla-device.yaml
INFO[0.1680610333] GUID and AUTHKEY: loading from file /var/local/supla-device/guid_auth.yaml
INFO[0.1680610333]  *** Starting supla-device ***
INFO[0.1680610333] Using config file /home/pi/supla-device/extras/examples/linux/supla-device.yaml
INFO[0.1680610333] Channel[0] config: adding ElectricityMeterParsed
DEBUG[0.1680610333] Supla - starting initialization
INFO[0.1680610333] Storage state file: /var/local/supla-device/state.bin
DEBUG[0.1680610333] Storage initialization
DEBUG[0.1680610333] Storage: missing Supla tag. Rewriting...
DEBUG[0.1680610333] Security level: 2
DEBUG[0.1680610333] Validating storage state section with current device configuration
INFO[0.1680610333] Storage state section validation completed. Loading elements state...
ERR[0.1680610333] JSON key "total_energy_consumption_tariff_1_kwh" not found
ERR[0.1680610333] JSON key "total_energy_consumption_tariff_2_kwh" not found
ERR[0.1680610333] JSON key "total_energy_production_tariff_1_kwh" not found
ERR[0.1680610333] JSON key "total_energy_production_tariff_2_kwh" not found
ERR[0.1680610333] JSON key "current_power_consumption_kw" not found
ERR[0.1680610333] JSON key "current_power_production_kw" not found
ERR[0.1680610333] JSON key "voltage_at_phase_1_v" not found
ERR[0.1680610333] JSON key "voltage_at_phase_2_v" not found
ERR[0.1680610333] JSON key "voltage_at_phase_3_v" not found
DEBUG[0.1680610333] Starting linux timers...
DEBUG[0.1680610333] Initializing network layer
DEBUG[0.1680610333] Network AP/hostname: MY-FANCY-DEVICE
INFO[0.1680610333] Using Supla protocol version 16
INFO[0.1680610333] Current status: [5] SuplaDevice initialized
INFO[0.1680610333] Enter normal mode
WARNING[0.1680610333] Connecting without certificate validation (INSECURE)
INFO[0.1680610333] Establishing encrypted connection with: svr12.supla.org (port: 2016)
DEBUG[0.1680610333] Connected with TLS_AES_256_GCM_SHA384 encryption
DEBUG[0.1680610333] Server certificates:
DEBUG[0.1680610333] Subject: /C=PL/ST=Opolskie/L=Paczkow/O=SUPLA.ORG/OU=Public Cloud Services/CN=svr12.supla.org/[email protected]
DEBUG[0.1680610333] Issuer: /C=PL/ST=Opolskie/L=Paczkow/O=SUPLA.ORG/OU=CA/CN=SUPLA.ORG CA/[email protected]
INFO[0.1680610333] Connected to Supla Server
INFO[0.1680610333] LAST STATE ADDED: Register in progress
INFO[0.1680610333] Current status: [10] Register in progress
INFO[0.1680610335] LAST STATE ADDED: Bad credentials - incorrect AuthKey or email
INFO[0.1680610335] Current status: [25] Bad credentials - incorrect AuthKey or email
ERR[0.1680610338] JSON key "total_energy_consumption_tariff_1_kwh" not found
ERR[0.1680610338] JSON key "total_energy_consumption_tariff_2_kwh" not found
ERR[0.1680610338] JSON key "total_energy_production_tariff_1_kwh" not found
ERR[0.1680610338] JSON key "total_energy_production_tariff_2_kwh" not found
ERR[0.1680610338] JSON key "current_power_consumption_kw" not found
ERR[0.1680610338] JSON key "current_power_production_kw" not found
ERR[0.1680610338] JSON key "voltage_at_phase_1_v" not found
ERR[0.1680610338] JSON key "voltage_at_phase_2_v" not found
ERR[0.1680610338] JSON key "voltage_at_phase_3_v" not found
ERR[0.1680610343] JSON key "total_energy_consumption_tariff_1_kwh" not found
ERR[0.1680610343] JSON key "total_energy_consumption_tariff_2_kwh" not found
ERR[0.1680610343] JSON key "total_energy_production_tariff_1_kwh" not found
ERR[0.1680610343] JSON key "total_energy_production_tariff_2_kwh" not found
ERR[0.1680610343] JSON key "current_power_consumption_kw" not found
ERR[0.1680610343] JSON key "current_power_production_kw" not found
ERR[0.1680610343] JSON key "voltage_at_phase_1_v" not found
ERR[0.1680610343] JSON key "voltage_at_phase_2_v" not found
ERR[0.1680610343] JSON key "voltage_at_phase_3_v" not found
WARNING[0.1680610345] Connecting without certificate validation (INSECURE)
INFO[0.1680610345] Establishing encrypted connection with: svr12.supla.org (port: 2016)
DEBUG[0.1680610345] Connected with TLS_AES_256_GCM_SHA384 encryption
DEBUG[0.1680610345] Server certificates:
DEBUG[0.1680610345] Subject: /C=PL/ST=Opolskie/L=Paczkow/O=SUPLA.ORG/OU=Public Cloud Services/CN=svr12.supla.org/[email protected]
DEBUG[0.1680610345] Issuer: /C=PL/ST=Opolskie/L=Paczkow/O=SUPLA.ORG/OU=CA/CN=SUPLA.ORG CA/[email protected]
INFO[0.1680610345] Connected to Supla Server
INFO[0.1680610347] Current status: [25] Bad credentials - incorrect AuthKey or email
ERR[0.1680610348] JSON key "total_energy_consumption_tariff_1_kwh" not found
ERR[0.1680610348] JSON key "total_energy_consumption_tariff_2_kwh" not found
ERR[0.1680610348] JSON key "total_energy_production_tariff_1_kwh" not found
ERR[0.1680610348] JSON key "total_energy_production_tariff_2_kwh" not found
ERR[0.1680610348] JSON key "current_power_consumption_kw" not found
ERR[0.1680610348] JSON key "current_power_production_kw" not found
ERR[0.1680610348] JSON key "voltage_at_phase_1_v" not found
ERR[0.1680610348] JSON key "voltage_at_phase_2_v" not found
ERR[0.1680610348] JSON key "voltage_at_phase_3_v" not found
ERR[0.1680610353] JSON key "total_energy_consumption_tariff_1_kwh" not found
ERR[0.1680610353] JSON key "total_energy_consumption_tariff_2_kwh" not found
ERR[0.1680610353] JSON key "total_energy_production_tariff_1_kwh" not found
ERR[0.1680610353] JSON key "total_energy_production_tariff_2_kwh" not found
ERR[0.1680610353] JSON key "current_power_consumption_kw" not found
ERR[0.1680610353] JSON key "current_power_production_kw" not found
ERR[0.1680610353] JSON key "voltage_at_phase_1_v" not found
ERR[0.1680610353] JSON key "voltage_at_phase_2_v" not found
ERR[0.1680610353] JSON key "voltage_at_phase_3_v" not found
WARNING[0.1680610357] Connecting without certificate validation (INSECURE)
INFO[0.1680610357] Establishing encrypted connection with: svr12.supla.org (port: 2016)
DEBUG[0.1680610357] Connected with TLS_AES_256_GCM_SHA384 encryption
DEBUG[0.1680610357] Server certificates:
DEBUG[0.1680610357] Subject: /C=PL/ST=Opolskie/L=Paczkow/O=SUPLA.ORG/OU=Public Cloud Services/CN=svr12.supla.org/[email protected]
DEBUG[0.1680610357] Issuer: /C=PL/ST=Opolskie/L=Paczkow/O=SUPLA.ORG/OU=CA/CN=SUPLA.ORG CA/[email protected]
INFO[0.1680610357] Connected to Supla Server
ERR[0.1680610358] JSON key "total_energy_consumption_tariff_1_kwh" not found
ERR[0.1680610358] JSON key "total_energy_consumption_tariff_2_kwh" not found
ERR[0.1680610358] JSON key "total_energy_production_tariff_1_kwh" not found
ERR[0.1680610358] JSON key "total_energy_production_tariff_2_kwh" not found
ERR[0.1680610358] JSON key "current_power_consumption_kw" not found
ERR[0.1680610358] JSON key "current_power_production_kw" not found
ERR[0.1680610358] JSON key "voltage_at_phase_1_v" not found
ERR[0.1680610358] JSON key "voltage_at_phase_2_v" not found
ERR[0.1680610358] JSON key "voltage_at_phase_3_v" not found
^CINFO[0.1680610359] Exit
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

[email protected] wrote: Tue Apr 04, 2023 12:17 pm Męczę się jeszcze z dwoma sprawami
"Connected" pojawia się, gdy nawiązane jest połączenie, po którym dopiero urządzenie się rejestruje. Następnie rejestracja nie przechodzi.
Sprawdź czy nie masz może dodanaego tego urządzenia w Cloud. Jeśli jest, to je usuń i włącz rejestrację urządzeń.

Code: Select all

ERR[0.1680610333] JSON key "total_energy_consumption_tariff_1_kwh" not found
Te logi świadczą o tym, że nie wpisałeś poprawnych danych do parsowania Twojego pliku json z licznika energii.
Konfigurację kanału licznika energii musisz poprawić i podać mu skąd ma odczytywać dane dla każdego parametru.

Trochę nie rozumiem czym jest ten plik json, który podałeś.
Aby licznik działał, musisz mieć jakąś integrację (program), który odczytuje dane z licznika i zapisuje je do pliku. Może to być format json, albo zwykły plik tekstowy z każdym parametrem w osobnej linijce.
Natomiast w pliku yaml konfigurujesz jak te dane mają być odczytywane.
Najlepsze suple dla Twojego domu :mrgreen:
[email protected]
Posts: 12
Joined: Mon Apr 03, 2023 6:47 pm

Post

sprawa 2

załatwione...miałem nie właściwy adres servera. Trzeba go pobrać dokładnie ze swojego konta na supla.

Po zalogowaniu przez weba idź do adresu: xxx.supla.org/account

Code: Select all

supla cloud 22.12.01
[email protected]

Adres serwera:  xxx.supla.org
Poprzednie logowanie:  4.04.2023, 15:03
Z adresu IP:  xxx.xxx.xxx.55
i skopiować Adres serwera i wstawić do pliku: supla-device.yaml w pole server:
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

[email protected] wrote: Tue Apr 04, 2023 1:46 pm Po zalogowaniu przez weba idź do adresu: xxx.supla.org/account
Adres serwera jest też dostępny na https://cloud.supla.org/home
Najlepsze suple dla Twojego domu :mrgreen:
[email protected]
Posts: 12
Joined: Mon Apr 03, 2023 6:47 pm

Post

Trochę nie rozumiem czym jest ten plik json, który podałeś.
Aby licznik działał, musisz mieć jakąś integrację (program), który odczytuje dane z licznika i zapisuje je do pliku. Może to być format json, albo zwykły plik tekstowy z każdym parametrem w osobnej linijce.
Natomiast w pliku yaml konfigurujesz jak te dane mają być odczytywane.
Napiszę jak rozumiem to jak działa supla device:

1. Supla-device łączy się z serverem supla.org i rejestruje na nim
2. Na podstawie supla-device.yaml w sekcji file:

Code: Select all

channels:
  - type: ElectricityMeterParsed
    parser:
      type: Json
    source:
      type: File
      file: "/var/local/supla-device/tauron.json"
aplikacja wie że ma pobierać dane z pliku: /var/local/supla-device/tauron.json, który to plik jest uaktualniany za pomocą jakiegoś zewnętrznego programu (na razie robię to ręcznie)

w powyższym poście podałem zawartość pliku tauron.json, żeby się poradzić czy jest prawidłowo zbudowany.

z tego co zrozumiałem to takowy plik json powinien być zbudowany w oparciu o supla-device.yaml, zawartość tego pliku poniżej:

Code: Select all

# Example supla-device config file for Linux device
# https://github.com/SUPLA/supla-device

name: My fancy device
log_level: debug
state_files_path: "/var/local/supla-device"
security_level: 2 # disable certyficate verification

supla:
  server: svr90.supla.org
  mail: [email protected]

channels:
  - type: ElectricityMeterParsed
    parser:
      type: Json
    source:
      type: File
      file: "/var/local/supla-device/tauron.json"
    phase_1:
      - voltage: voltage_at_phase_1_v
        multiplier: 1
      - fwd_act_energy: total_energy_consumption_tariff_1_kwh
        multiplier: 1
      - rvr_act_energy: total_energy_production_tariff_1_kwh
        multiplier: 1
      - power_active: current_power_consumption_kw
        multiplier: 1000
      - rvr_power_active: current_power_production_kw
        multiplier: 1000
    phase_2:
      - voltage: voltage_at_phase_2_v
        multiplier: 1
      - fwd_act_energy: total_energy_consumption_tariff_2_kwh
        multiplier: 1
      - rvr_act_energy: total_energy_production_tariff_2_kwh
        multiplier: 1
    phase_3:
      - voltage: voltage_at_phase_3_v
        multiplier: 1
Czy podany plik tauron.json jest dobrze zbudowany?
User avatar
klew
Posts: 13908
Joined: Thu Jun 27, 2019 12:16 pm
Location: Wrocław
Has thanked: 134 times
Been thanked: 137 times

Post

Trochę na odwrót.
W yaml dostosowujesz się do formatu pliku źródłowego, a nie na odwrót.
Także jak będziesz miał dane w pliku json, to w pliku yaml określasz jak to czytać
Najlepsze suple dla Twojego domu :mrgreen:
[email protected]
Posts: 12
Joined: Mon Apr 03, 2023 6:47 pm

Post

Hej dzięki za poradę, mega mi pomogła

Teraz wszystko działa jak ta lala... ;)

Urządzenie zarejestrowane na srv.supla.org....nice :lol:

Mam jeszcze pytanie o opcje cmd z dokumentacji w sekcji:

Parsed channel source parameter

Czy ta opcja pozwala wywołać skrypt np. python-a?

Return to “Ogólna dyskusja”