Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pas de sensor après l'ajout de l'addon #15

Open
mathgim opened this issue Nov 30, 2023 · 11 comments
Open

Pas de sensor après l'ajout de l'addon #15

mathgim opened this issue Nov 30, 2023 · 11 comments

Comments

@mathgim
Copy link

mathgim commented Nov 30, 2023

Bonjour,
Avant toute chose, merci pour ce superbe addon qui parait très utile et très prometteur !
J'ai ajouté l'addon à HassOS et les deux automations mais je n'ai pas de sensor lié à mes comptes grdf et veolia.

Voici ma config addon :

log_level: info
timeout: "30"
type: ha
logs_folder: /config
download_folder: /config
grdf_event: call_grdf
veolia_event: call_veolia
keep_output: true
screenshot: true
debug: true
skip_download: false
grdf_login: xxx (removed for confidentiality)
grdf_password: xxx (removed for confidentiality)
grdf_pce: xxx (removed for confidentiality)
mqtt_login: xxx (removed for confidentiality)
mqtt_password: xxx (removed for confidentiality)
mqtt_server: mqtt:https://homeassistant
mqtt_port: 1883
veolia_login: xxx (removed for confidentiality)
veolia_password: xxx (removed for confidentiality)
veolia_contract: xxx (removed for confidentiality)

Les deux automations :

- id: '1700871350360'
  alias: Appel GRDF
  description: ''
  trigger:
  - platform: time_pattern
    hours: '21'
    minutes: '1'
    seconds: '0'
  - platform: time_pattern
    hours: '23'
    minutes: '1'
    seconds: '0'
  condition:
  - condition: template
    value_template: '{{ (as_timestamp(now())-as_timestamp(states.sensor.gas_consumption_kwh.last_updated|default(''1970-01-01'')))
      > 17*3600 }}'
  action:
  - delay: '{{ range(0, 55*60+1) | random }}'
    alias: Avec un délai variable pour ne pas charger le serveur tous en même temps.
  - event: call_grdf
    event_data: {}
  mode: single
- id: '1700871397584'
  alias: Veolia
  description: Déclencher l'événement qui démarre l'application MetersToHa sous AppDaemon
  trigger:
  - platform: time_pattern
    hours: '1'
    minutes: '7'
    alias: Déclenchement à partir de l'heure choisie
  condition: []
  action:
  - delay: '{{ range(0, 90*60+1) | random }}'
    alias: Avec un délai variable pour ne pas charger le serveur tous en même temps.
  - event: call_meters_to_ha
    event_data: {}
    alias: Déclenche l'événement définit dans la configuration 'AppDaemon'
  mode: single

Et le log de l'addon :

 Home Assistant Supervisor: 2023.11.3
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
Log level is set to INFO
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Cloning into 'MetersToHA'...
git checkout 
Your branch is up to date with 'origin/meters-to-ha'.
MetersToHA Container version: dev.015 #ac6444fe6ea3619664657995d7eebd23  /run.sh
MetersToHA Python GIT version: 6a109f9 on Sat Nov 18 02:41:48 2023 +0100
Generate configuration file
Generated configuration file '/m2h_config.json':
{
    "log_level":"info",
    "logs_folder":"/config",
    "veolia_login":"xxx (removed for confidentiality)",
    "veolia_password":"xxx (removed for confidentiality)",
    "veolia_contract":"xxx (removed for confidentiality)",
    "grdf_login":"xxx (removed for confidentiality)",
    "grdf_password":"xxx (removed for confidentiality)",
    "grdf_pce":"xxx (removed for confidentiality)",
    "timeout":"30",
    "download_folder":"/config",
    "mqtt_server":"mqtt:https://homeassistant",
    "mqtt_port":"1883",
    "mqtt_login":"xxx (removed for confidentiality)",
    "mqtt_password":"xxx (removed for confidentiality)",
    "ha_server": "https://supervisor/core",
    "ha_token": "xxx (removed for confidentiality)",
    "type": "ha"
}
DISPLAY:''
EVENT CONF:grdf:call_grdf
=== Generated script '/execEvent.sh': ==========
#!/bin/bash
{
  TARGET_OPT=""
  [[ "$1" == "call_veolia" ]] && TARGET_OPT=--veolia
    [[ "$1" == "call_grdf" ]] && TARGET_OPT=--grdf
    
  [[ "$TARGET_OPT" == "" ]] && ( echo "Unrecognized event '$1'" ; exit 1 )
  date
  echo "python3  MetersToHA/apps/meters_to_ha/meters_to_ha.py  -l /config --debug --screenshot --keep-output -c \"/m2h_config.json\" $TARGET_OPT -r"
  python3  MetersToHA/apps/meters_to_ha/meters_to_ha.py  -l /config --debug --screenshot --keep-output -c "/m2h_config.json" $TARGET_OPT -r
  # Copy chrome logs
  for i in ~/.config/*/chrome_debug.log ; do
    [[ -r "$i" ]] || continue
    SUBDIR="/config/$(basename "$(dirname "$i")")"
    mkdir -p "${SUBDIR}"
    cp -p "$i" "${SUBDIR}"
  done
  echo "Done $(date)"
} >> "/config/m2h_exec.log" 2>&1
=== End of Generated script '/execEvent.sh': ===

Test access to Home Assistant API (should show '{"message":"API running."}')
{"message":"API running."}
"./haevent2exec.py" --config-json "/m2h_config.json" --external-program "/execEvent.sh" --log-level="info"  call_veolia call_grdf
[2023/11/28 22:56:36] (haevent2exec.py) INFO    Received {'type': 'auth_required', 'ha_version': '2023.11.3'}
[2023/11/28 22:56:36] (haevent2exec.py) INFO    Connected
[2023/11/28 22:56:36] (haevent2exec.py) INFO    Result of subscription for 'call_veolia': None
[2023/11/28 22:56:36] (haevent2exec.py) INFO    Result of subscription for 'call_grdf': None
[2023/11/28 22:56:36] (haevent2exec.py) INFO    send_event_msg: Got id (3,)
[2023/11/28 22:56:36] (haevent2exec.py) INFO    Subscribed, waiting for messages
[2023/11/28 22:56:36] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":1,"type":"result","success":true,"result":null}', extra='')
[2023/11/28 22:56:36] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":2,"type":"result","success":true,"result":null}', extra='')
[2023/11/28 23:30:19] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"event_type":"call_grdf","data":{},"origin":"LOCAL","time_fired":"2023-11-28T22:30:19.462080+00:00","context":{"id":"xxx (removed for confidentiality)","parent_id":null,"user_id":null}},"id":2}', extra='')
[2023/11/28 23:30:19] (haevent2exec.py) INFO    Received event: call_grdf
[2023/11/28 23:30:19] (haevent2exec.py) INFO    Start external program for call_grdf
[2023/11/28 23:30:22] (haevent2exec.py) INFO    send_event_msg: Got call_grdf ()
[2023/11/29 15:06:51] (haevent2exec.py) ERROR   Error: Cannot connect to host supervisor:80 ssl:default [Connect call failed ('172.30.32.2', 80)]
[2023/11/29 15:06:56] (haevent2exec.py) ERROR   Error: Cannot connect to host supervisor:80 ssl:default [Connect call failed ('172.30.32.2', 80)]
[2023/11/29 15:07:17] (haevent2exec.py) ERROR   Error: 400, message='Invalid response status', url=URL('https://supervisor/core/api/websocket')
[2023/11/29 15:07:22] (haevent2exec.py) ERROR   Error: 400, message='Invalid response status', url=URL('https://supervisor/core/api/websocket')
[2023/11/29 15:07:27] (haevent2exec.py) INFO    Received {'type': 'auth_required', 'ha_version': '2023.11.3'}
[2023/11/29 15:07:27] (haevent2exec.py) INFO    Connected
[2023/11/29 15:07:27] (haevent2exec.py) INFO    Result of subscription for 'call_veolia': None
[2023/11/29 15:07:27] (haevent2exec.py) INFO    Result of subscription for 'call_grdf': None
[2023/11/29 15:07:27] (haevent2exec.py) INFO    send_event_msg: Got id (3,)
[2023/11/29 15:07:27] (haevent2exec.py) INFO    Subscribed, waiting for messages
[2023/11/29 15:07:27] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":1,"type":"result","success":true,"result":null}', extra='')
[2023/11/29 15:07:27] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":2,"type":"result","success":true,"result":null}', extra='')
[2023/11/29 21:04:24] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"event_type":"call_grdf","data":{},"origin":"LOCAL","time_fired":"2023-11-29T20:04:24.246499+00:00","context":{"id":"xxx (removed for confidentiality)","parent_id":null,"user_id":null}},"id":2}', extra='')
[2023/11/29 21:04:24] (haevent2exec.py) INFO    Received event: call_grdf
[2023/11/29 21:04:24] (haevent2exec.py) INFO    Start external program for call_grdf
[2023/11/29 21:04:26] (haevent2exec.py) INFO    send_event_msg: Got call_grdf ()
[2023/11/29 23:33:34] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"event_type":"call_grdf","data":{},"origin":"LOCAL","time_fired":"2023-11-29T22:33:34.457369+00:00","context":{"id":"xxx (removed for confidentiality)","parent_id":null,"user_id":null}},"id":2}', extra='')
[2023/11/29 23:33:34] (haevent2exec.py) INFO    Received event: call_grdf
[2023/11/29 23:33:34] (haevent2exec.py) INFO    Start external program for call_grdf
[2023/11/29 23:33:36] (haevent2exec.py) INFO    send_event_msg: Got call_grdf ()
@mdeweerd
Copy link
Owner

[2023/11/29 15:06:51] (haevent2exec.py) ERROR Error: Cannot connect to host supervisor:80 ssl:default [Connect call failed ('172.30.32.2', 80)]
[2023/11/29 15:07:27] (haevent2exec.py) INFO Received {'type': 'auth_required', 'ha_version': '2023.11.3'}

Le problème est là - l'addon n'arrive pas à se connecter à home-assistant. - c'est étrange qu'il n'arrive pas à s'authentifier - la valeur "ha_token" est bel et bien généré automatiquemen et non spécifié dans la configuration (du moins c'est ce que je vois);

Sinon - pour info - pour utiliser mqtt, il faut mettre "type" à mqtt. Avec 'ha' cela devrait quand même fonctionner.

Peut-être qu'il y a eu une anomalie et que le add-on a un token qui n'est plus valide - un redémarrage non réussi, ... ?
Dans un premier temps, je propose de redemarrer le add-on pour écarter cette possibilité.

@mathgim
Copy link
Author

mathgim commented Nov 30, 2023

Oui en effet, ha_token est généré automatiquement.
Dois-je modifier la config et retirer les champs mqtt? Par quelle intégration vont arriver les sensors ? Ai-je une manipulation manuelle à effectuer dans HA pour les voir ?
J'ai essayé de redémarrer entièrement HA mais cela n'a rien fait.

@mdeweerd
Copy link
Owner

C'est l'option type: ha qui défini par ou les données arrivent - pas besoin de retirer le reste de la configuration. Avec type: mqtt, cela arrive par mqtt, mais ha c'est mieux quand cela fonctionne.

Sinon, mets "debug: false" - c'est un paramètre historique et je pense que je le changerai un jour - c'est quand on fait du débogue avec une fenètre X.

log_level: info -> log_level: debug permets de voir plus. Mais le problème c'est peut-être simplement le "debug: true".

Car on a aussi eu une connexion correcte, donc le problème de connexion était visiblement transitoire:

[2023/11/29 23:33:34] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"event_type":"call_grdf","data":{},"origin":"LOCAL","time_fired":"2023-11-29T22:33:34.457369+00:00","context":{"id":"xxx (removed for confidentiality)","parent_id":null,"user_id":null}},"id":2}', extra='')
[2023/11/29 23:33:34] (haevent2exec.py) INFO    Received event: call_grdf
[2023/11/29 23:33:34] (haevent2exec.py) INFO    Start external program for call_grdf
[2023/11/29 23:33:36] (haevent2exec.py) INFO    send_event_msg: Got call_grdf ()

@mathgim
Copy link
Author

mathgim commented Nov 30, 2023

Merci pour ta réponse. Ca n'a rien changé. J'ai temporairement changé les tempos aléatoires des deux automations. Quand je trigger l'automation veolia, rien ne se passe dans les logs. Quand je trigger l'automation grdf, les 5 dernières lignes s'affichent.
J'ai changé le nom de l'event call_meters_to_ha en call_veolia dans l'automation veolia et là j'ai eu ensuite le log de cet automation. Doc à changer il me semble du coup :-)

Où suis-je censé trouvé les nouveaux sensors ? Sous quels noms ? Je ne cherche peut-être pas tout simplement au bon endroit..

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting
-----------------------------------------------------------

 Add-on: MetersToHA
 MetersToHA add-on for Home Assistant
-----------------------------------------------------------
 Add-on version: dev
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.1  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2023.11.3
 Home Assistant Supervisor: 2023.11.6
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
Log level is set to DEBUG
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Cloning into 'MetersToHA'...
git checkout 
Your branch is up to date with 'origin/meters-to-ha'.
MetersToHA Container version: dev.015 #ac6444fe6ea3619664657995d7eebd23  /run.sh
MetersToHA Python GIT version: ebf6f4f on Thu Nov 30 22:59:08 2023 +0100
Generate configuration file
Generated configuration file '/m2h_config.json':
{
    "log_level":"debug",
    "logs_folder":"/config",
    "veolia_login":"xxx (removed for confidentiality)",
    "veolia_password":"xxx (removed for confidentiality)",
    "veolia_contract":"xxx (removed for confidentiality)",
    "grdf_login":"xxx (removed for confidentiality)",
    "grdf_password":"xxx (removed for confidentiality)",
    "grdf_pce":"xxx (removed for confidentiality)",
    "timeout":"30",
    "download_folder":"/config",
    "mqtt_server":"mqtt:https://homeassistant",
    "mqtt_port":"1883",
    "mqtt_login":"xxx (removed for confidentiality)",
    "mqtt_password":"xxx (removed for confidentiality)",
    "ha_server": "https://supervisor/core",
    "ha_token": "xxx (removed for confidentiality)",
    "type": "ha"
}
DISPLAY:''
EVENT CONF:grdf:call_grdf
=== Generated script '/execEvent.sh': ==========
#!/bin/bash
{
  TARGET_OPT=""
  [[ "$1" == "call_veolia" ]] && TARGET_OPT=--veolia
    [[ "$1" == "call_grdf" ]] && TARGET_OPT=--grdf
    
  [[ "$TARGET_OPT" == "" ]] && ( echo "Unrecognized event '$1'" ; exit 1 )
  date
  echo "python3  MetersToHA/apps/meters_to_ha/meters_to_ha.py  -l /config --screenshot --keep-output -c \"/m2h_config.json\" $TARGET_OPT -r"
  python3  MetersToHA/apps/meters_to_ha/meters_to_ha.py  -l /config --screenshot --keep-output -c "/m2h_config.json" $TARGET_OPT -r
  # Copy chrome logs
  for i in ~/.config/*/chrome_debug.log ; do
    [[ -r "$i" ]] || continue
    SUBDIR="/config/$(basename "$(dirname "$i")")"
    mkdir -p "${SUBDIR}"
    cp -p "$i" "${SUBDIR}"
  done
  echo "Done $(date)"
} >> "/config/m2h_exec.log" 2>&1
=== End of Generated script '/execEvent.sh': ===

Test access to Home Assistant API (should show '{"message":"API running."}')
curl -H 'Authorization: Bearer xxx (removed for confidentiality)' -H 'Content-Type: application/json' https://supervisor/core/api/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    26  100    26    0     0    816      0 --:--:-- --:--:-- --:--:--   838
{"message":"API running."}
"./haevent2exec.py" --config-json "/m2h_config.json" --external-program "/execEvent.sh" --log-level="debug"  call_veolia call_grdf
[2023/12/01 00:15:36] (haevent2exec.py) INFO    Received {'type': 'auth_required', 'ha_version': '2023.11.3'}
[2023/12/01 00:15:36] (haevent2exec.py) INFO    Connected
[2023/12/01 00:15:36] (haevent2exec.py) INFO    Result of subscription for 'call_veolia': None
[2023/12/01 00:15:36] (haevent2exec.py) INFO    Result of subscription for 'call_grdf': None
[2023/12/01 00:15:36] (haevent2exec.py) INFO    send_event_msg: Got id (3,)
[2023/12/01 00:15:36] (haevent2exec.py) INFO    Subscribed, waiting for messages
[2023/12/01 00:15:36] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":1,"type":"result","success":true,"result":null}', extra='')
[2023/12/01 00:15:36] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":2,"type":"result","success":true,"result":null}', extra='')
[2023/12/01 00:16:58] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"event_type":"call_grdf","data":{},"origin":"LOCAL","time_fired":"2023-11-30T23:16:58.471963+00:00","context":{"id":"xxx (removed for confidentiality)","parent_id":"xxx (removed for confidentiality)","user_id":null}},"id":2}', extra='')
[2023/12/01 00:16:58] (haevent2exec.py) INFO    Received event: call_grdf
[2023/12/01 00:16:58] (haevent2exec.py) DEBUG   Run_on_event: ha
[2023/12/01 00:16:58] (haevent2exec.py) INFO    Start external program for call_grdf
[2023/12/01 00:16:58] (haevent2exec.py) DEBUG   Run_on_event: kill
[2023/12/01 00:19:27] (haevent2exec.py) DEBUG   Run_on_event: process_done
[2023/12/01 00:19:27] (haevent2exec.py) INFO    send_event_msg: Got call_grdf ()
[2023/12/01 00:27:28] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"event_type":"call_veolia","data":{},"origin":"LOCAL","time_fired":"2023-11-30T23:27:28.641276+00:00","context":{"id":"xxx (removed for confidentiality)","parent_id":"xxx (removed for confidentiality)","user_id":null}},"id":1}', extra='')
[2023/12/01 00:27:28] (haevent2exec.py) INFO    Received event: call_veolia
[2023/12/01 00:27:28] (haevent2exec.py) DEBUG   Run_on_event: ha
[2023/12/01 00:27:28] (haevent2exec.py) INFO    Start external program for call_veolia
[2023/12/01 00:27:28] (haevent2exec.py) DEBUG   Run_on_event: kill
[2023/12/01 00:28:42] (haevent2exec.py) DEBUG   Run_on_event: process_done
[2023/12/01 00:28:42] (haevent2exec.py) INFO    send_event_msg: Got call_veolia ()

@mathgim
Copy link
Author

mathgim commented Nov 30, 2023

C'est normal ça au moment de l'initialisation ?
Result of subscription for 'call_veolia': None

@albebert
Copy link

albebert commented Apr 22, 2024

Bonjour,

je semble avoir le même comportement.

Ma conf :

log_level: debug
timeout: "30"
type: ha
logs_folder: /config
download_folder: /config
grdf_event: call_grdf
veolia_event: call_veolia
keep_output: true
screenshot: true
display: false
skip_download: false
grdf_login: rxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
grdf_password: xxxxxxxxxxxxxxxxxxxxxxxxx
grdf_pce: "xxxxxxxxxxxxxxxx"

logs :

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting

-----------------------------------------------------------
 Add-on: MetersToHA
 MetersToHA add-on for Home Assistant
-----------------------------------------------------------
 Add-on version: dev
 You are running the latest version of this add-on.
 System: Debian GNU/Linux 12 (bookworm)  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2024.4.3
 Home Assistant Supervisor: 2024.04.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
Log level is set to DEBUG
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Cloning into 'MetersToHA'...
git checkout 
Your branch is up to date with 'origin/meters-to-ha'.
MetersToHA Container version: dev.017 #2815b130869d0d7b049de3b0fc03f3e3  /run.sh
MetersToHA Python GIT version: 30665a2 on Fri Mar 1 17:59:13 2024 +0100
Generate configuration file
Generated configuration file '/m2h_config.json':
{
    "log_level":"debug",
    "logs_folder":"/config",
    "grdf_login":"xxxxxxxxxxxxxxxxxx",
    "grdf_password":"xxxxxxxxxxxxxxxxxxxxx",
    "grdf_pce":"xxxxxxxx",
    "timeout":"30",
    "download_folder":"/config",
    "ha_server": "https://supervisor/core",
    "ha_token": "bb649e0c96558435xxxxx9dd7d0bf1544e273080ba3868d4b070d",
    "type": "ha"
}
DISPLAY:''
EVENT CONF: veolia:call_veolia grdf:call_grdf
=== Generated script '/execEvent.sh': ==========
#!/bin/bash
{
  TARGET_OPT=""
  [[ "$1" == "call_veolia" ]] && TARGET_OPT=--veolia
    [[ "$1" == "call_grdf" ]] && TARGET_OPT=--grdf
    [[ "$1" == "homeassistant_started" ]] && TARGET_OPT="-k --skip-download  --veolia --grdf"

  [[ "$TARGET_OPT" == "" ]] && ( echo "Unrecognized event '$1'" ; exit 1 )
  date
  echo "python3  MetersToHA/apps/meters_to_ha/meters_to_ha.py  -l /config --screenshot --keep-output -c \"/m2h_config.json\" $TARGET_OPT -r"
  python3  MetersToHA/apps/meters_to_ha/meters_to_ha.py  -l /config --screenshot --keep-output -c "/m2h_config.json" $TARGET_OPT -r
  # Copy chrome logs
  for i in ~/.config/*/chrome_debug.log ; do
    [[ -r "$i" ]] || continue
    SUBDIR="/config/$(basename "$(dirname "$i")")"
    mkdir -p "${SUBDIR}"
    cp -p "$i" "${SUBDIR}"
  done
  echo "Done $(date)"
} >> "/config/m2h_exec.log" 2>&1
=== End of Generated script '/execEvent.sh': ===

Test access to Home Assistant API (should show '{"message":"API running."}')
curl -H 'Authorization: Bearer bb649e0c96558435b92de8f7778669d8ca797ea353eaf6287726859d65445cd65e3ca9606db63ba69dd7d0bf1544e273080ba3868d4b070d' -H 'Content-Type: application/json' https://supervisor/core/api/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    26  100    26    0     0   1196      0 --:--:-- --:--:-- --:--:--  1238
{"message":"API running."}
"./haevent2exec.py" --config-json "/m2h_config.json" --external-program "/execEvent.sh" --log-level="debug"  call_veolia call_grdf homeassistant_started
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Received {'type': 'auth_required', 'ha_version': '2024.4.3'}
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Connected
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Result of subscription for 'call_veolia': None
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Result of subscription for 'call_grdf': None
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Result of subscription for 'homeassistant_started': None
[2024/04/22 21:04:09] (haevent2exec.py) INFO    send_event_msg: Got id (4,)
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Subscribed, waiting for messages
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":1,"type":"result","success":true,"result":null}', extra='')
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":2,"type":"result","success":true,"result":null}', extra='')
[2024/04/22 21:04:09] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"id":3,"type":"result","success":true,"result":null}', extra='')
[2024/04/22 21:07:59] (haevent2exec.py) INFO    Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"event","event":{"event_type":"call_grdf","data":{},"origin":"REMOTE","time_fired":"2024-04-22T19:07:59.452388+00:00","context":{"id":"01HW3KAE2WG1JQTDAXKHKS067Q","parent_id":null,"user_id":"a944e7ed747742c38be82147d080bc30"}},"id":2}', extra='')
[2024/04/22 21:07:59] (haevent2exec.py) INFO    Received event: call_grdf
[2024/04/22 21:07:59] (haevent2exec.py) DEBUG   Run_on_event: ha
[2024/04/22 21:07:59] (haevent2exec.py) INFO    Start external program for call_grdf
[2024/04/22 21:07:59] (haevent2exec.py) DEBUG   Run_on_event: kill
[2024/04/22 21:09:50] (haevent2exec.py) DEBUG   Run_on_event: process_done
[2024/04/22 21:09:50] (haevent2exec.py) INFO    send_event_msg: Got call_grdf ()

je ne trouve pas d'autres logs :/

@albebert
Copy link

service.log :


2024-04-22 20:42:58,886 : WW :  Encountered error -> Retrying once
2024-04-22 20:43:25,937 : OK : Connexion au site GRDF
2024-04-22 20:43:56,148 : EE : Waiting for Password Message: failed, page timeout (timeout=30)
2024-04-22 20:43:56,606 : OK : Close Browser
2024-04-22 20:43:56,617 : OK : Close Display
2024-04-22 20:43:56,618 : EE :  Ended with error : // re-run with '--display' option if you can
2024-04-22 21:08:00,580 : OK : Using /usr/bin/python3 Version 3.11.8Loading configuration file : /m2h_config.json
2024-04-22 21:08:00,584 : -- :  Start loading configuration
2024-04-22 21:08:00,585 : OK : "veolia" = "False"
2024-04-22 21:08:00,585 : OK : "veolia_login" = "None"
2024-04-22 21:08:00,586 : OK : "veolia_password" = "None"
2024-04-22 21:08:00,586 : OK : "veolia_contract" = "None"
2024-04-22 21:08:00,587 : OK : "grdf" = "True"
2024-04-22 21:08:00,587 : OK : "grdf_login" = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
2024-04-22 21:08:00,587 : OK : "grdf_password" = "***************"
2024-04-22 21:08:00,588 : OK : "grdf_pce" = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
2024-04-22 21:08:00,588 : OK : "screenshot" = "True"
2024-04-22 21:08:00,589 : OK : "skip_download" = "False"
2024-04-22 21:08:00,589 : OK : "keep_output" = "True"
2024-04-22 21:08:00,589 : WW :  "geckodriver" not found in config file, using default value
2024-04-22 21:08:00,590 : OK : "geckodriver" = "/MetersToHA/apps/meters_to_ha/geckodriver"
2024-04-22 21:08:00,590 : WW :  "firefox" not found in config file, using default value
2024-04-22 21:08:00,590 : OK : "firefox" = "/MetersToHA/apps/meters_to_ha/firefox"
2024-04-22 21:08:00,591 : WW :  "chromium" not found in config file, using default value
2024-04-22 21:08:00,591 : OK : "chromium" = "/usr/bin/chromium"
2024-04-22 21:08:00,591 : WW :  "chromedriver" not found in config file, using default value
2024-04-22 21:08:00,592 : OK : "chromedriver" = "/usr/bin/chromedriver"
2024-04-22 21:08:00,592 : OK : "chrome_version" = "None"
2024-04-22 21:08:00,592 : OK : "timeout" = "30"
2024-04-22 21:08:00,593 : OK : "download_folder" = "/config/"
2024-04-22 21:08:00,593 : OK : "logs_folder" = "/config/"
2024-04-22 21:08:00,594 : OK : "2captcha_token" = "None"
2024-04-22 21:08:00,594 : OK : "capmonster_token" = "None"
2024-04-22 21:08:00,594 : OK : "captchaai_token" = "None"
2024-04-22 21:08:00,595 : OK : "log_level" = "debug"
2024-04-22 21:08:00,595 : OK : End loading configuration
2024-04-22 21:08:00,595 : -- :  Start Loading Home Assistant configuration
2024-04-22 21:08:00,596 : OK : "ha_server" = "https://supervisor/core"
2024-04-22 21:08:00,596 : OK : "ha_token" = "****************************************************************************************************************"
2024-04-22 21:08:00,597 : OK : "veolia_contract" = "None"
2024-04-22 21:08:00,597 : OK : "timeout" = "30"
2024-04-22 21:08:00,597 : OK : "insecure" = "False"
2024-04-22 21:08:00,598 : OK : "state_file" = "/config/meters2ha_state.json"
2024-04-22 21:08:00,598 : OK : End loading Home Assistant configuration
2024-04-22 21:08:00,598 : ~~ :  Check availability of "geckodriver"+"firefox" or "chromedriver"+"chromium"
2024-04-22 21:08:00,599 : OK :  Found chromium binary
2024-04-22 21:08:00,627 : OK : Check Home Assistant connectivity
2024-04-22 21:08:00,628 : -- : Try starting Chromium. Add nix root user options.
2024-04-22 21:08:03,036 : OK : Start virtual display (Chromium).
2024-04-22 21:08:03,036 : ~~ :  LOG LEVEL debug:10:20 ['--verbose']
2024-04-22 21:08:14,836 : OK : Start the browser
2024-04-22 21:08:14,857 : OK :
2024-04-22 21:08:44,654 : OK : Connexion au site GRDF
2024-04-22 21:09:14,966 : WW : Waiting for Password Traceback (most recent call last): -   File "//MetersToHA/apps/meters_to_ha/meters_to_ha.py", line 3439, in doWork -     gazpar_file = crawler.get_gazpar_file() -                   ^^^^^^^^^^^^^^^^^^^^^^^^^ -   File "//MetersToHA/apps/meters_to_ha/meters_to_ha.py", line 1756, in get_gazpar_file -     el_password = self.__wait.until( -                   ^^^^^^^^^^^^^^^^^^ -   File "/usr/lib/python3.11/site-packages/selenium/webdriver/support/wait.py", line 105, in until -     raise TimeoutException(message, screen, stacktrace) - selenium.common.exceptions.TimeoutException: Message: failed, page timeout (timeout=30) -
2024-04-22 21:09:14,967 : WW :  Encountered error -> Retrying once
2024-04-22 21:09:20,060 : OK : Connexion au site GRDF
2024-04-22 21:09:50,086 : EE : Waiting for Password Message: failed, page timeout (timeout=30)
2024-04-22 21:09:50,576 : OK : Close Browser
2024-04-22 21:09:50,582 : OK : Close Display
2024-04-22 21:09:50,583 : EE :  Ended with error : // re-run with '--display' option if you can

@albebert
Copy link

en utilisant le script de vingerha présent sur sa PR ça fonctionne à merveille (remplacer à la main dans le docker pour le moment)

@foux
Copy link

foux commented Apr 23, 2024

en utilisant le script de vingerha présent sur sa PR ça fonctionne à merveille (remplacer à la main dans le docker pour le moment)

Hello @albebert. J'ai le même soucis. Êtes-vous sur HAOS? Si oui comment rempalcez vous le fichier dans l'addon? Merci!

@albebert
Copy link

@foux , alors j'ai une custom install (HA supervised sur raspbian x64) , du coup j'ai accès direct à docker, donc j'ai juste lancer un bash sur docker et le faire à la main

@foux
Copy link

foux commented Apr 23, 2024

Thanks, c'est ce que je craignais. Pas vraiment possible à faire sur un HAOS je pense. J'espère que la PR va être mergée rapidement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants