#Device conditions

1 messages · Page 1 of 1 (latest)

edgy haven
#

I am having a real difficult time using the new device condition selector. I swear it doesn't show everything. I have a bambu p1s. I have a card showing me print status. However, when I go into automations, I can't find it. What I want to do is turn off the power (smart switch) at 11:55pm if the printer is idle, however, I can't find it as a condition.

Anybody run into this before?

regal perch
#

Select entity state as condition type, then use the entity that tells you the state

edgy haven
#

Interesting. Thanks I will try that

storm hedge
#

I've had a very hard time getting my P1S to play nice with automations.

#

What I've done is to use the Current stage entity, and just have it trigger whenever it changes. In the "Then" I use a "choose" and template conditions. For example, I have a strip of ws2814 (RGB+WW) leds in a riser at the top of the printer. I wanted to replace the built in light with the strip, and have the new light come on full brightness while printing, but "turn off" to a gentle animation. To detect when a print starts, Current stage changes from 'cleaning_nozzle_tip' to 'auto_bed_leveling'.

#

I unplugged the built-in light and used a device trigger for "P1S Printer Chamber light turned on or off". I again used a "choose" and template conditions, where I just check if it was turned on or off and act accordingly. If it's "off" (meaning it's set to the animation effect with different colors) then I save the current settings in a temporary scene, then set the effect to none and the color and white to 100% brightness. If I'm turning if off, I just apply the scene that I saved to restore whatever colors I had it set to.

#

You could check a few different entities to see if the printer is active. Active tray should be "unavailable" when not printing. Current stage usually goes to "idle" when not printing. You shouldn't have a hotend or bed target temp when not printing, so you could check if those are 0. Print status is another one.

warped sage
#

@storm hedge Can you just share the yaml?

humble pineBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

storm hedge
# warped sage <@197038219060183040> Can you just share the yaml?

Yeah, sorry, I thought I could explain it more concisely. Here's the YAML for detecting when a print starts, this turns the light on and starts an external camera recording:

description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.p1s_printer_current_stage
conditions: []
actions:
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ trigger.to_state.state == 'auto_bed_leveling' and
              trigger.from_state.state == 'cleaning_nozzle_tip' }}
        sequence:
          - action: light.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: light.p1s_printer_chamber_light
          - type: turn_on
            device_id: 3013397c203ad10712498facb3f8a937
            entity_id: a399703227cad6110bdcd504f1bc97a8
            domain: switch
            enabled: true
        alias: Auto Bed Leveling -> Printing
      - conditions:
          - condition: template
            value_template: "{{ trigger.from_state.state == 'printing' }}"
        sequence:
          - type: turn_off
            device_id: 3013397c203ad10712498facb3f8a937
            entity_id: a399703227cad6110bdcd504f1bc97a8
            domain: switch
        alias: Done Printing
mode: single
#

This one overrides the "on/off" of the built-in light (which I've unplugged in the machine) with the strip of ws281x:

description: ""
triggers:
  - type: changed_states
    device_id: 14d9f437b0b78b5d027778d8425beecd
    entity_id: ba118446b6b9f51e97946a943630f397
    domain: light
    trigger: device
conditions: []
actions:
  - variables:
      p1s_lavalamp: |-
        {{set(states.light
          | selectattr('attributes.friendly_name', 'contains', 'Bambu P1S')
          | map(attribute='entity_id'))
          | list}}
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.state == 'on' }}"
        sequence:
          - action: scene.create
            metadata: {}
            data:
              scene_id: bambu_printer
              snapshot_entities: "{{ p1s_lavalamp }}"
          - action: light.turn_on
            metadata: {}
            data:
              effect: None
              rgbw_color:
                - 179
                - 179
                - 179
                - 255
              brightness_pct: 100
            target:
              entity_id: "{{ p1s_lavalamp }}"
        alias: Light on Lava off
      - conditions:
          - condition: template
            value_template: "{{ trigger.to_state.state == 'off' }}"
        sequence:
          - action: scene.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: scene.bambu_printer
        alias: Light off Lava on
mode: single