« Info:: SHELLY prise 230V connectée » : différence entre les versions

De wiki_pcwiki2
Aller à la navigationAller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 4 : Ligne 4 :


  '''Le 24/05/2026:'''
  '''Le 24/05/2026:'''
  Pour allumer à distance une lampe rouge à la Gacerie (''pour que Geneviève sache qu'on arrive pas à la joindre''), j'ai acheté une prise Shelly.
  Pour allumer à distance une lampe rouge à la Gacerie (''pour que Geneviève sache qu'on arrive pas à la joindre''), j'ai acheté une prise Shelly (''Shelly Plug S Gen3 Blanc - Prise connectée 12 A (2500 W): '''21 euros''''').
<pre>
Il y a 3 modes:
root@srv18:~# curl -s http://192.168.1.246/shelly
- '''local''' (uniquement sur '''srv18''')
{"name":null,"id":"shellyplugsg3-9070694d1430","mac":"9070694D1430","slot":1,"model":"S3PL-00112EU","gen":3,"fw_id":"20251113-160645/1.7.3-gb71e9ac","ver":"1.7.3","app":"PlugSG3","auth_en":false,"auth_domain":null,"matter":true}
  - '''cloud''' (cloud Shelly)
</pre>
- '''pcstreet''' (cloud PCStreet sur '''ovh1''')
  Il s'agit d'une '''Shelly Plus Plug S de Génération 3''' (''que j'ai plugguée en 192.168.1.246'')
  On peut passer d'un mode à l'autre en définissant simplement le '''BACKEND'''
  Pour connaître toutes les caractéristiques:
  au début du fichier srv18::/usr/lib/cgi-bin/shelly.sh:
  curl -s http://192.168.1.246/rpc/Shelly.GetConfig
    BACKEND="cloud"
<pre>
ou BACKEND="local"
root@srv18:~# curl -s http://192.168.1.246/rpc/Shelly.GetConfig
ou BACKEND="pcstreet"
{"ble":{"enable":true,"rpc":{"enable":true}},"bthome":{},"cloud":{"enable":true,"server":"shelly-261-eu.shelly.cloud:6022/jrpc"},"knx":{"enable":false,"ia":"15.15.255","routing":{"addr":"224.0.23.12:3671"}},"matter":{"enable":true},"mqtt":{"enable":false,"server":null,"client_id":"shellyplugsg3-9070694d1430","user":null,"ssl_ca":null,"topic_prefix":"shellyplugsg3-9070694d1430","rpc_ntf":true,"status_ntf":false,"use_client_cert":false,"enable_rpc":true,"enable_control":true},"plugs_ui":{"leds":{"mode":"power","colors":{"switch:0":{"on":{"rgb":[0.000,100.000,0.000],"brightness":100.000},"off":{"rgb":[100.000,0.000,0.000],"brightness":100.000}},"power":{"brightness":100.000}},"night_mode":{"enable":false,"brightness":100.000,"active_between":[]}},"controls":{"switch:0":{"in_mode":"momentary"}}},"switch:0":{"id":0, "name":null,"initial_state":"restore_last", "auto_on":false, "auto_on_delay":60.00, "auto_off":false, "auto_off_delay":60.00,"power_limit":2500,"voltage_limit":280,"autorecover_voltage_errors":false,"current_limit":12.000,"reverse":false},"sys":{"device":{"name":null,"mac":"9070694D1430","fw_id":"20251113-160645/1.7.3-gb71e9ac","discoverable":true,"eco_mode":false},"location":{"tz":"Europe/Paris","lat":48.858200,"lon":2.338700},"debug":{"level":2,"file_level":null,"mqtt":{"enable":false},"websocket":{"enable":false},"udp":{"addr":null}},"ui_data":{},"rpc_udp":{"dst_addr":null,"listen_port":null},"sntp":{"server":"time.cloudflare.com"},"cfg_rev":8},"wifi":{"ap":{"ssid":"ShellyPlugSG3-9070694D1430","is_open":true, "enable":true, "range_extender": {"enable":false}},"sta":{"ssid":null,"is_open":true, "enable":false, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"sta1":{"ssid":"Freebox-CA0C41-2.4Ghz","is_open":false, "enable":true, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"roam":{"rssi_thr":-80,"interval":60}},"ws":{"enable":false,"server":null,"ssl_ca":"ca.pem"}}
 
</pre>
  '''Mosquitto''' est installé sur ovh1 et fait le relais pour le Shelly
 
On peut gérer la lampe rouge de Geneviève:
  Pour '''sauvegarder''' les valeurs actuelles: '''curl -s http://192.168.1.246/rpc/Shelly.GetConfig > /WEB/genevieve.thabard.com/sauvegardeShelly.20260524.json'''
- en mode CLI: srv18::/WEB/genevieve.thabard.com/CGI-BIN/mqtt.[on|off|statut].sh
- en mode WEB: srv18::/WEB/genevieve.thabard.com/index.html
   
   
  Pour '''restaurer''': '''curl -s -X POST http://192.168.1.246/rpc/Shelly.SetConfig -d @/WEB/genevieve.thabard.com/sauvegardeShelly.20260524.json'''
  Le plus simple est d'utiliser le backend pcstreet:
   
MQTT_HOST="mqtt.thabard.com"
Pour ajouter les fonctionnalités '''mosquitto''' au Shelly:
  MQTT_HOST_BACKUP="mqtt.thabard.com"
curl -s -X POST http://192.168.1.246/rpc/MQTT.SetConfig -d '{
MQTT_PORT="1883"
  "config": {
MQTT_USER="srv18"
    "enable": true,
  MQTT_PASS="fromspace"
    "server": "192.168.1.18:1883",
  MQTT_DEVICE="plug_salon"
    "user": "srv18",
  MQTT_SWITCH_ID="0"
    "pass": "fromspace",
    "topic_prefix": "shelly/plug_salon"
  }
}'
  Attention: réponse du Shelly: {"restart_required":true} (''il faut redémarrer le Shelly'')
'''curl -s http://192.168.1.246/rpc/Shelly.Reboot'''
'''Reboot''':
curl -s http://192.168.1.246/rpc/Shelly.Reboot
 
Maintenant récupérons le statut via mosquitto: (''Attention: cela prend du temps''):
'''mosquitto_sub -h 127.0.0.1 -p 1883 -u srv18 -P fromspace -t "shelly/plug_salon/#" -v
Shelly/plug_salon/online true'''
 
  Allumons la lampe via mosquitto:
mosquitto_pub -h 127.0.0.1 -p 1883 -u srv18 -P fromspace -t "shelly/plug_salon/rpc" -m '{"method":"Switch.Set", "params":{"id":0, "on":true}}'
  Éteignons la lampe:
mosquitto_pub -h 127.0.0.1 -p 1883 -u srv18 -P fromspace -t "shelly/plug_salon/rpc" -m '{"method":"Switch.Set", "params":{"id":0, "on":false}}'
Obtenons le status immédiatement:
mosquitto_pub -h 127.0.0.1 -p 1883 -u srv18 -P fromspace -t "shelly/plug_salon/rpc" -m '{"method":"Switch.GetStatus", "params":{"id":0}}'

Version du 24 mai 2026 à 14:03

KEYWORDS: SHELLY - GACERIE - LAMPE ROUGE

Info::SHELLY prise 230V connectée: explications Le 24/05/2026
Le 24/05/2026:
Pour allumer à distance une lampe rouge à la Gacerie (pour que Geneviève sache qu'on arrive pas à la joindre), j'ai acheté une prise Shelly (Shelly Plug S Gen3 Blanc - Prise connectée 12 A (2500 W): 21 euros).
Il y a 3 modes:
- local (uniquement sur srv18)
- cloud (cloud Shelly)
- pcstreet (cloud PCStreet sur ovh1)
On peut passer d'un mode à l'autre en définissant simplement le BACKEND 
au début du fichier srv18::/usr/lib/cgi-bin/shelly.sh: 
   BACKEND="cloud"
ou BACKEND="local"
ou BACKEND="pcstreet"
 
Mosquitto est installé sur ovh1 et fait le relais pour le Shelly
On peut gérer la lampe rouge de Geneviève:
- en mode CLI: srv18::/WEB/genevieve.thabard.com/CGI-BIN/mqtt.[on|off|statut].sh
- en mode WEB: srv18::/WEB/genevieve.thabard.com/index.html

Le plus simple est d'utiliser le backend pcstreet:
MQTT_HOST="mqtt.thabard.com"
MQTT_HOST_BACKUP="mqtt.thabard.com"
MQTT_PORT="1883"
MQTT_USER="srv18"
MQTT_PASS="fromspace"
MQTT_DEVICE="plug_salon"
MQTT_SWITCH_ID="0"