Skip to content

Commit

Permalink
Handle protocol deviation for early Linky
Browse files Browse the repository at this point in the history
Handle protocol deviation for early ADS. Currently ADS 67 only is concerned. 68 could also be concerned.
Deviation :
SINSTS -> SINST1
SMAXSN -> SMAXN,
SAMXSN-1 -> SMAXMN-1
  • Loading branch information
jipem01 committed Oct 28, 2024
1 parent 407748b commit 591595b
Showing 1 changed file with 81 additions and 33 deletions.
114 changes: 81 additions & 33 deletions custom_components/linkytic/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,39 +288,6 @@ async def async_setup_entry(
register_callback=True,
conversion_function=(lambda x: x * 1000) # kVA conversion
),
RegularIntSensor(
tag="SINSTS",
name="Puissance app. instantanée soutirée",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
),
RegularIntSensor(
tag="SMAXSN",
name="Puissance app. max. soutirée n",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
),
RegularIntSensor(
tag="SMAXSN-1",
name="Puissance app. max. soutirée n-1",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
),
RegularIntSensor(
tag="CCASN",
name="Point n de la courbe de charge active soutirée",
Expand Down Expand Up @@ -654,6 +621,87 @@ async def async_setup_entry(
category=EntityCategory.DIAGNOSTIC,
),
]
# Handle protocol deviation for experimental/pilote modules
if (serial_reader.device_identification[DID_TYPE_CODE]=="67"):
sensors.append(
RegularIntSensor(
tag="SINST1",
name="Puissance app. instantanée soutirée",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
)
)
sensors.append(
RegularIntSensor(
tag="SMAXN",
name="Puissance app. max. soutirée n",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
)
)
sensors.append(
RegularIntSensor(
tag="SMAXN-1",
name="Puissance app. max. soutirée n-1",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
)
)
else:
sensors.append(
RegularIntSensor(
tag="SINSTS",
name="Puissance app. instantanée soutirée",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
)
)
sensors.append(
RegularIntSensor(
tag="SMAXSN",
name="Puissance app. max. soutirée n",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
)
)
sensors.append(
RegularIntSensor(
tag="SMAXSN-1",
name="Puissance app. max. soutirée n-1",
config_title=config_entry.title,
config_uniq_id=config_entry.entry_id,
serial_reader=serial_reader,
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=UnitOfApparentPower.VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT,
register_callback=True,
)
)
# Add producer specific sensors
if bool(config_entry.data.get(SETUP_PRODUCER)):
sensors.append(
Expand Down

0 comments on commit 591595b

Please sign in to comment.