Помощь в арифметическом пересчете кода RCSwitch

There is a ESP8266 module with ESPHome firmware. The working firmware code receives the code from the remote radiothermometer in BIN and DEC format. DEC format code is displayed on the homeassistant WEB panel. I need to recalculate the DEC code so that the temperature is readable. Conversion formula (code - 300,000-500 )\10. Tell the guys how to add or correct the code. I know that I need to make changes to the section and then to the function, but I don’t understand how to do this.

esphome:
name: esphome-web-58e44f
friendly_name: ESPHome Web 58e44f
min_version: 2025.11.0
name_add_mac_suffix: false

esp8266:
board: nodemcuv2
restore_from_flash: True

preferences:
flash_write_interval: 300s

Enable logging

logger:

Enable Home Assistant API

api:

Allow Over-The-Air updates

ota:

  • platform: esphome

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

captive_portal:

one_wire:

  • platform: gpio
    pin: GPIO2

sensor:

  • platform: dallas_temp
    name: “Температура дома”
    update_interval: 10s
    address: 0x5d181e3e31672128
    #- platform: dallas_temp

name: “Temperature #2

address: 0xDD0000031EFB0428

  • platform: adc
    pin: GPIO17
    name: “Напряжение питания”
    update_interval: 2s
    unit_of_measurement: “V”
    accuracy_decimals: 2
    filters:
    • multiply: 3.27

switch:

  • platform: gpio
    name: “Relay 1”
    pin: GPIO12
    id: ‘living1’
    restore_mode: RESTORE_DEFAULT_OFF

  • platform: gpio
    name: “Relay 2”
    pin: GPIO14
    id: ‘living2’
    restore_mode: RESTORE_DEFAULT_OFF

remote_receiver:

  • pin:
    number: D3
    mode: INPUT_PULLUP
    inverted: True
    dump: rc_switch
    tolerance: 60%
    filter: 4us
    idle: 4ms
    buffer_size: 2kb
    on_rc_switch:
    #- logger.log:
    #format: “on_rc_switch: %i %llu”
    #args: [x.protocol, x.code]
    then:
    - lambda: |-
    char str[20];
    sprintf(str, “%llu”, x.code);
    id(rf_code).publish_state(str);
    #- lambda: |-
    # ESP_LOGI(“rc_switch”, “Received: %ld, Protocol: %d, Bits: %d”, x.code, x.protocol, x.bits);
    #// Здесь можно конвертировать, например, x.code

text_sensor:

  • platform: template
    name: “Температура улица”
    id: rf_code
    icon: “mdi:thermometer”

binary_sensor:

  • platform: template
    name: “Test Door”
    device_class: door
    id: testdoor

  • platform: remote_receiver
    name: “Test Door Open”
    internal: true
    on_press:
    then:
    - binary_sensor.template.publish:
    id: testdoor
    state: ON
    - switch.toggle: living1 # реле <Relay 1> вкл/выкл одной кнопкой
    #- switch.turn_on: living1 # реле <Relay 1> вкл разными кнопками
    rc_switch_raw:
    code: ‘100001111001000000110001’
    protocol: 6
    filters:

    • delayed_off: 100ms
  • platform: remote_receiver
    name: “Test Door Close”
    internal: true
    on_press:
    then:
    - binary_sensor.template.publish:
    id: testdoor
    state: OFF
    - switch.toggle: living2 # реле <Relay 2> вкл/выкл одной кнопкой
    #- switch.turn_off: living2 # реле <Relay 2> выкл разными кнопками
    rc_switch_raw:
    code: ‘100001111001000000110010’
    protocol: 6
    filters:

    • delayed_off: 100ms

Two things that would help us help us. First, this is an English forum. If you don’t read/write English, please use a translation service. Second, please format your YAML code so it’s readable. See: