diff --git a/esphome/components/modbus_controller/number/__init__.py b/esphome/components/modbus_controller/number/__init__.py index 4ad6601fee..56ec734315 100644 --- a/esphome/components/modbus_controller/number/__init__.py +++ b/esphome/components/modbus_controller/number/__init__.py @@ -58,8 +58,7 @@ def validate_modbus_number(config): CONFIG_SCHEMA = cv.All( - number.NUMBER_SCHEMA.extend(ModbusItemBaseSchema) - .extend( + number.NUMBER_SCHEMA.extend(ModbusItemBaseSchema).extend( { cv.GenerateID(): cv.declare_id(ModbusNumber), cv.Optional(CONF_VALUE_TYPE, default="U_WORD"): cv.enum(SENSOR_VALUE_TYPE), @@ -72,8 +71,7 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_MULTIPLY, default=1.0): cv.float_, cv.Optional(CONF_USE_WRITE_MULTIPLE, default=False): cv.boolean, } - ) - .extend(cv.polling_component_schema("60s")), + ), validate_min_max, validate_modbus_number, ) diff --git a/tests/test5.yaml b/tests/test5.yaml index b13f20a9b2..55786050b3 100644 --- a/tests/test5.yaml +++ b/tests/test5.yaml @@ -14,8 +14,8 @@ esp32: wifi: networks: - - ssid: 'MySSID' - password: 'password1' + - ssid: "MySSID" + password: "password1" manual_ip: static_ip: 192.168.1.23 gateway: 192.168.1.1 @@ -39,7 +39,6 @@ uart: i2c: - modbus: uart_id: uart1 flow_control_pin: 5 @@ -50,13 +49,20 @@ modbus_controller: address: 0x2 modbus_id: mod_bus1 - binary_sensor: - platform: gpio pin: GPIO0 id: io0_button icon: mdi:gesture-tap-button + - platform: modbus_controller + modbus_controller_id: modbus_controller_test + id: modbus_binsensortest + register_type: read + address: 0x3200 + bitmask: 0x80 #(bit 8) + lambda: !lambda "{ return x ;}" + tlc5947: data_pin: GPIO12 clock_pin: GPIO14 @@ -75,6 +81,14 @@ output: - platform: mcp47a1 id: output_mcp47a1 + - platform: modbus_controller + modbus_controller_id: modbus_controller_test + id: modbus_output_test + lambda: |- + return x * 1.0 ; + address: 0x9001 + value_type: U_WORD + demo: esp32_ble: @@ -104,9 +118,20 @@ number: max_value: 100 min_value: 0 step: 5 - unit_of_measurement: '%' + unit_of_measurement: "%" mode: slider + - id: modbus_numbertest + platform: modbus_controller + modbus_controller_id: modbus_controller_test + name: "ModbusNumber" + address: 0x9002 + value_type: U_WORD + lambda: "return x * 1.0; " + write_lambda: |- + return x * 1.0 ; + multiply: 1.0 + select: - platform: template name: My template select @@ -170,8 +195,7 @@ sensor: name: "SelecEM2M Maximum Demand Apparent Power" disabled_by_default: true - - id: battery_voltage - name: "Battery voltage2" + - id: modbus_sensortest platform: modbus_controller modbus_controller_id: modbus_controller_test address: 0x331A @@ -200,6 +224,14 @@ script: then: - logger.log: "looping!" +switch: + - platform: modbus_controller + modbus_controller_id: modbus_controller_test + id: modbus_switch_test + register_type: coil + address: 2 + bitmask: 1 + ektf2232: interrupt_pin: GPIO36 rts_pin: GPIO5