migration from ha-cantegrill repo

This commit is contained in:
2024-05-31 14:50:50 +02:00
commit 45376aebcb
20 changed files with 2998 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
sensor.with_state_and_attribute: 'SomeRandomState'
sensor.with_state_and_attribute.off: 'off'
sensor.with_state_and_attribute.on: 'on'
sensor.with_state_and_attribute.f127: 127
sensor.with_only_attribute.on: 'on'
sensor.None: #None
constants:
self: sensor.with_state_and_attribute
pi: 3.14
tests:
test_1:
expected_result: Succeeded
conditions: sensor.with_state_and_attribute.on
test_2:
expected_result: Succeeded
#TODO: find a way to make it work without parenthesis
#conditions: (sensor.with_state_and_attribute.on and binary_sensor.on) == not binary_sensor.false
conditions: (sensor.with_state_and_attribute.on and binary_sensor.on) == (not binary_sensor.false)
test_3:
expected_result: Succeeded
conditions: sensor.with_state_and_attribute.f127 < sensor.int170
test_4:
expected_result: ParsingException
conditions: sensor.with_only_attribute.on != binary_sensor.on
test_5:
expected_result: Succeeded
#TODO: find a way to make it work without parenthesis
#conditions: (self.on and binary_sensor.on) == not binary_sensor.false
conditions: (self.on and binary_sensor.on) == (not binary_sensor.false)
test_6:
expected_result: Succeeded
conditions: self.f127 < sensor.int170
test_7:
expected_result: ParsingException
conditions: pi.on != binary_sensor.on

58
unit_tests/test_bool.yaml Normal file
View File

@@ -0,0 +1,58 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
binary_sensor.nottrue: False
constants:
andtrap: False
tests:
test_1:
expected_result: Succeeded
conditions: binary_sensor.true or binary_sensor.false
test_2:
expected_result: Failed
conditions: binary_sensor.true and binary_sensor.false
test_3:
expected_result: Succeeded
conditions: binary_sensor.on or binary_sensor.off
test_4:
expected_result: Failed
conditions: binary_sensor.on and binary_sensor.off == False
test_5:
expected_result: Succeeded
conditions: binary_sensor.true or binary_sensor.false and binary_sensor.false
test_6:
expected_result: Failed
conditions: (binary_sensor.true or binary_sensor.false) and binary_sensor.false
test_7:
expected_result: Succeeded
conditions: not binary_sensor.off
test_8:
expected_result: Failed
conditions: not binary_sensor.on
test_9:
expected_result : Succeeded
conditions: binary_sensor.true == (not binary_sensor.false)
test_10:
conditions: binary_sensor.nottrue == andtrap
expected_result: Succeeded

View File

@@ -0,0 +1,37 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
tests:
test_1:
expected_result: Succeeded
conditions: sensor.int200 > 115 and (sensor.int200 < 190 or (binary_sensor.on and sensor.int200 < 220))
test_2:
expected_result: Failed
conditions: (sensor.int170 * 2) < sensor.int200
test_3:
expected_result: Failed
conditions: not not binary_sensor.off
test_4:
expected_result: Succeeded
#TODO: find a way to make it work without parenthesis
#conditions: (binary_sensor.on and binary_sensor.on) == not binary_sensor.false
conditions: (binary_sensor.on and binary_sensor.on) == (not binary_sensor.false)
test_5:
expected_result: Succeeded
conditions: (binary_sensor.on and binary_sensor.on) == True

View File

@@ -0,0 +1,53 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
sensor.None: #None
constants:
self: sensor.int170
selftrue: binary_sensor.true
pi: 3.14
tests:
test_1:
expected_result: Succeeded
conditions: binary_sensor.true and True
test_2:
expected_result: Failed
conditions: binary_sensor.true and False
test_3:
expected_result: Succeeded
conditions: sensor.strNuit != None
test_4:
expected_result: Succeeded
conditions: sensor.None == None
test_5:
expected_result: Succeeded
conditions: self > 160
test_6:
expected_result: Failed
conditions: self < 160
test_7:
expected_result: Succeeded
conditions: pi * 2 == 6.28
test_8:
expected_result: Succeeded
conditions: selftrue and not sensor.strHome == 'Nuit'

View File

@@ -0,0 +1,54 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
sensor.None: #None
sensor.with_state_and_attribute: 'SomeRandomState'
sensor.with_state_and_attribute.off: 'off'
sensor.with_state_and_attribute.on: 'on'
sensor.with_state_and_attribute.f127: 127
constants:
self: sensor.int170
pi: 3.14
tests:
test_1:
expected_result: Succeeded
expected_entities_to_listen:
- binary_sensor.true
conditions: binary_sensor.true and True
test_2:
expected_result: Succeeded
expected_entities_to_listen:
- binary_sensor.true
- binary_sensor.false
conditions: (binary_sensor.true and binary_sensor.false) or binary_sensor.true
test_3:
expected_result: Succeeded
expected_entities_to_listen:
- sensor.int170
- sensor.float10
conditions: self > sensor.float10
test_4:
expected_result: Succeeded
expected_entities_to_listen:
- sensor.float5
conditions: pi < sensor.float5
test_5:
expected_result: Failed
expected_entities_to_listen:
- sensor.float5
- sensor.with_state_and_attribute
- sensor.with_state_and_attribute.on
- sensor.with_state_and_attribute.f127
conditions: (sensor.with_state_and_attribute.f127 > sensor.float5 or sensor.with_state_and_attribute.on) and sensor.with_state_and_attribute == 'randomstring'

View File

@@ -0,0 +1,26 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
tests:
test_1:
expected_result: ParsingException
conditions: (binary_sensor.true or binary_sensor.false
test_2:
expected_result: ParsingException
conditions: (binary_sensor.true and) binary_sensor.false
test_3:
expected_result: ParsingException
conditions: binary_sensor.on or binary_sensore.off

View File

@@ -0,0 +1,60 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
sensor.strNuit.int80: 70
constants:
self: binary_sensor.true
tests:
test_1:
expected_result: Succeeded
conditions:
trigger_conditions:
- sensor.int170 < 10 and sensor.int17 >= 28
- self and not sensor.strNuit == 'Nuit'
- sensor.int170 >= 34
test_2:
expected_result: Disabled
conditions:
trigger_conditions:
- binary_sensor.false and sensor.int170 > 15
- not binary_sensor.off and sensor.int170 > 65
disable_conditions:
- sensor.strNuit.int80 < 80 and sensor.strNuit.int80 > 40
- sensor.strNuit == 'Nuit'
test_3:
expected_result: Failed
conditions:
trigger_conditions:
- binary_sensor.off and binary_sensor.true
- binary_sensor.true
blocking_conditions: self and not binary_sensor.off
disable_conditions: binary_sensor.off
test_4:
expected_result: Disabled
conditions:
trigger_conditions:
- binary_sensor.true and (not binary_sensor.on or binary_sensor.off)
- binary_sensor.false and binary_sensor.on
- binary_sensor.on and not binary_sensor.true
blocking_conditions: not binary_sensor.off
disable_conditions:
- binary_sensor.off
- not binary_sensor.false and sensor.strNuit == 'Nuit'

View File

@@ -0,0 +1,38 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
tests:
test_1:
expected_result: Succeeded
conditions: binary_sensor.true and (sensor.strHome == 'home' and sensor.float10 > 1)
test_2:
expected_result: Failed
conditions: binary_sensor.true and (sensor.strHome != 'home' and sensor.float10 > 1)
test_3:
expected_result: Failed
conditions: not binary_sensor.off and not binary_sensor.on and sensor.strNuit == 'Nuit'
test_4:
expected_result: Failed #this test will make the parser crash if the and operator evaluate the second operand wether the first one is true or false
conditions: sensor.strHome != 'home' and sensor.strHome < 15
test_5:
expected_result: Succeeded
conditions: sensor.float10 != 'Home' and sensor.float10 < 15

View File

@@ -0,0 +1,46 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
binary_sensor.nottrue: False
constants:
andtrap: False
templates_library:
T1: binary_sensor.true or binary_sensor.false
T2: binary_sensor.on and binary_sensor.off == False
T3:
trigger_conditions: binary_sensor.off == False
blocking_conditions:
- binary_sensor.on
tests:
test_1:
expected_result: Succeeded
conditions: <T1>
test_2:
expected_result: Succeeded
conditions:
template_conditions: <T2>
trigger_conditions: binary_sensor.true
test_3:
expected_result: Succeeded
conditions: <T1>, <T2>
test_4:
expected_result: Failed
conditions:
template_conditions: <T2>,<T3>
trigger_conditions: binary_sensor.true and binary_sensor.false

View File

@@ -0,0 +1,56 @@
fake_entities:
binary_sensor.true: True
binary_sensor.false: False
binary_sensor.off: 'off'
binary_sensor.on: 'on'
sensor.int17: 17
sensor.int170: 170
sensor.int200: 200
sensor.int3: 3
sensor.float10: 10.0
sensor.float5: 5.0
sensor.strNuit: 'Nuit'
sensor.strHome: 'home'
sensor.none:
tests:
test_1:
expected_result: Succeeded
conditions: "(binary_sensor.on ? 10 : 0) > sensor.int3"
test_2:
expected_result: Succeeded
conditions: "(binary_sensor.on ? sensor.float10 : 0) > sensor.int3"
test_3:
expected_result: Failed
conditions: "binary_sensor.off ? (binary_sensor.on or binary_sensor.off) : binary_sensor.off"
test_4:
expected_result: Failed
conditions: "binary_sensor.on ? binary_sensor.on and binary_sensor.off : binary_sensor.on"
test_5:
expected_result: Succeeded
conditions: "((binary_sensor.on or binary_sensor.false) ? 5 : 1) > sensor.int3"
test_6:
expected_result: Failed
conditions: "((binary_sensor.on and binary_sensor.false) ? 5 : 1) > sensor.int3"
test_7:
expected_result: Succeeded
conditions: "(binary_sensor.on ? sensor.float10 : 0) > sensor.int3"
test_none_ternary:
expected_result: Failed
conditions: "sensor.none != None ? sensor.none > 75 : False"
# test_15:
# expected_result: Succeeded
# conditions: "(binary_sensor.off ? (binary_sensor.on or binary_sensor.off) : (binary_sensor.off ? sensor.int3 : sensor.int17)) > sensor.int3"