FEAT : Girouette OK
This commit is contained in:
parent
4ca0462d58
commit
661a1c7cb3
@ -26,13 +26,6 @@ wifi:
|
|||||||
ssid: !secret wifi_ssid
|
ssid: !secret wifi_ssid
|
||||||
password: !secret wifi_password
|
password: !secret wifi_password
|
||||||
|
|
||||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
||||||
ap:
|
|
||||||
ssid: "Seeed-Studio Fallback Hotspot"
|
|
||||||
password: "FrTglhXBIVqi"
|
|
||||||
|
|
||||||
captive_portal:
|
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin: GPIO21 # Led de la carte
|
pin: GPIO21 # Led de la carte
|
||||||
@ -41,19 +34,6 @@ output:
|
|||||||
pin: GPIO3 # le pin connecté à DE/RE
|
pin: GPIO3 # le pin connecté à DE/RE
|
||||||
id: DE_RE
|
id: DE_RE
|
||||||
|
|
||||||
switch:
|
|
||||||
- platform: output
|
|
||||||
name: "LED"
|
|
||||||
output: led_output
|
|
||||||
id: led_switch
|
|
||||||
restore_mode: ALWAYS_OFF
|
|
||||||
|
|
||||||
interval:
|
|
||||||
- interval: 5s
|
|
||||||
then:
|
|
||||||
- switch.toggle: led_switch
|
|
||||||
- logger.log: "rbo2"
|
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
id: mod_bus_id
|
id: mod_bus_id
|
||||||
tx_pin: GPIO44 # Il faut les inverser !!!!
|
tx_pin: GPIO44 # Il faut les inverser !!!!
|
||||||
@ -78,6 +58,12 @@ modbus_controller:
|
|||||||
setup_priority: -10
|
setup_priority: -10
|
||||||
command_throttle: 2s
|
command_throttle: 2s
|
||||||
update_interval: 4s
|
update_interval: 4s
|
||||||
|
- id: modbus_controller2
|
||||||
|
address: 2
|
||||||
|
modbus_id: modbus1
|
||||||
|
setup_priority: -10
|
||||||
|
command_throttle: 2s
|
||||||
|
update_interval: 4s
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: modbus_controller
|
- platform: modbus_controller
|
||||||
@ -105,12 +91,25 @@ sensor:
|
|||||||
then:
|
then:
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "rbo2"
|
topic: "rbo2"
|
||||||
payload: !lambda 'return to_string(x);'
|
payload: !lambda 'return "Vent --> " + to_string(x);'
|
||||||
|
- platform: modbus_controller
|
||||||
|
modbus_controller_id: modbus_controller2
|
||||||
|
name: "Wind direction gear"
|
||||||
|
internal: true
|
||||||
|
register_type: read
|
||||||
|
address: 0
|
||||||
|
value_type: U_WORD
|
||||||
|
accuracy_decimals: 0
|
||||||
|
on_value:
|
||||||
|
then:
|
||||||
|
- mqtt.publish:
|
||||||
|
topic: "rbo2"
|
||||||
|
payload: !lambda 'return "Sens --> " + to_string(x);'
|
||||||
|
|
||||||
mqtt:
|
mqtt:
|
||||||
broker: "pc-raymond.home"
|
broker: "pc-raymond.home"
|
||||||
id: mqtt1
|
id: mqtt1
|
||||||
log_topic: rbo
|
log_topic: rbo
|
||||||
birth_message:
|
birth_message:
|
||||||
topic: rbo2
|
topic: rbo2
|
||||||
payload: 'send_every: 1 !'
|
payload: 'Nouvelle connexion...'
|
||||||
24
proto/ecrire.py
Executable file
24
proto/ecrire.py
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!python
|
||||||
|
from pymodbus.client import ModbusSerialClient, ModbusTcpClient
|
||||||
|
from pymodbus.pdu.register_read_message import ReadInputRegistersResponse
|
||||||
|
from configModel import Algo, Metrique, Capteur, ModbusType
|
||||||
|
import struct, time
|
||||||
|
|
||||||
|
# client = ModbusTcpClient(host="shellyproem50-08f9e0e79718") # grarage (borne et pac)
|
||||||
|
# client = ModbusTcpClient(host="ShellyPro3EM-FCE8C0D97664") # bureau (prises 1 à 3)
|
||||||
|
client = ModbusSerialClient(
|
||||||
|
port="/dev/ttyACM0",
|
||||||
|
baudrate=4800,
|
||||||
|
# stopbits=capteur.comConfig.stopbits,
|
||||||
|
# bytesize=capteur.comConfig.bytesize,
|
||||||
|
# parity=capteur.comConfig.parity
|
||||||
|
)
|
||||||
|
|
||||||
|
slave = 1
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
registre = 2000
|
||||||
|
print(f"On force le registre {registre} (adresse modbus) à 2")
|
||||||
|
client.connect()
|
||||||
|
client.write_register(2000, 2, slave=slave)
|
||||||
|
client.close()
|
||||||
@ -22,10 +22,12 @@ def uint32(a, b):
|
|||||||
ret:int = (a << 16) | b
|
ret:int = (a << 16) | b
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
slave = 1
|
||||||
|
|
||||||
def lireMetrique(metrique:Metrique, registre):
|
def lireMetrique(metrique:Metrique, registre):
|
||||||
client.connect()
|
client.connect()
|
||||||
try:
|
try:
|
||||||
data:ReadInputRegistersResponse = client.read_input_registers(registre, 2, slave=1)
|
data:ReadInputRegistersResponse = client.read_input_registers(registre, 2, slave=slave)
|
||||||
if data:
|
if data:
|
||||||
print(f"--> {data}")
|
print(f"--> {data}")
|
||||||
registres = data.registers
|
registres = data.registers
|
||||||
@ -48,6 +50,7 @@ def lireMetrique(metrique:Metrique, registre):
|
|||||||
registre = -1
|
registre = -1
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
slave = 2
|
||||||
while True:
|
while True:
|
||||||
registre = 0
|
registre = 0
|
||||||
m:Metrique = Metrique(
|
m:Metrique = Metrique(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user