Skip to content

Exceptions are not explicit enough #107

Closed
@wsw70

Description

@wsw70

I wrote yesterday a simple automation for three rooms to have their shutters move up and lights switched off (both cover.<someone> and group.<someone> exist (the latter being a set of switches that manage lights))

@time_trigger("once(09:45)")
def volets_matin_total():
    for who in ['martin', 'michael', 'parents']:
        cover.open_cover(entity_id=f"cover.{who}_volets")
        homeassistant.turn_off(f"group.{who}")

I got this morning the follwing error (first time it actually ran - I do not think there is a way to test a pyscript automation the same way as in the GUI where there is the 'Execute' function)

2020-12-03 09:45:00 ERROR (MainThread) [custom_components.pyscript.file.volets.volets_matin_total] Exception in <file.volets.volets_matin_total> line 15:
            homeassistant.turn_off(f"group.{who}")
                                            ^
TypeError: exceptions must derive from BaseException

So something bad happened (not yet sure what) but the traceback is not very talkative because it seems that this is rather an information about the nature of the raised Exception not being correct rather than the traceback of the error in my code itself. This is not the first time I see that.

Or maybe I misunderstood something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions