Active sensor by closed doors instead at open doors

Hi there,

Is there any way to have a active sensor by closed doors. I would like to have a binary sensor group that is active when all doors are closed, use less than 8 kWh power usage and temperature between 17 and 23 degrees.

This is the first step. At the end I would like that HA is going to deside what is the best option to using gas or electricity based on electricity price and gasprice and usage. Beside COP from my ac and Central heater and open doors. With a open door it’s not recommended to use.

Many thanks

There are probably several possible solutions here. I would do it in your place with a template sensor that switches on when your various conditions are met and otherwise switches off.

For example something like this:

template:
  - binary_sensor:
      - name: My Template Sensor 
        state: >
          {{ is_state('binary_sensor.sensor1', 'off') and is_state('binary_sensor.sensor2', 'off') }}