MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-PIR-Sensor-Lite modification

    Scheduled Pinned Locked Moved Solved Troubleshooting
    27 Posts 4 Posters 13.7k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F Offline
      Freddy_boy
      last edited by

      Re: PIR problem

      I have also been experiencing similar problems with my PIR sensor since upgrading to Bullseye. After trying numerous modules, I inquired about suggestions for updated modules that have been known to work with Bullseye and posted a request in the forum (https://forum.magicmirror.builders/topic/17810/pir-sensor-for-raspbian-11). It seems that many have chosen to go with the MMM-PIR-Sensor-Lite module, so I will pose my question here.

      My PIR sensor appears to function properly and after the standby timeout, the HDMI output will turn off (I am using the ‘xrandr’ command type). However, this results in my monitor detecting a missing signal and it will put up a “No Signal” indication on the screen. Further, after a certain time, it will turn the monitor OFF, which requires that I need to push buttons in order to turn it back on again. My understanding is that I need to use HDMI CEC commands in order to instruct the monitor to turn off, which will prevent the “No Signal” indication from appearing. This was a completely working feature in my Magic Mirror prior to upgrading to Bullseye.

      I used the EXT-Pir and EXT-Screen modules (https://wiki.bugsounet.fr/) in the past and they were able to accomplish the task. However, I don’t have enough skill to examine the code to determine how the commands are being sent to turn off my monitor. The EXT-Screen module simply required that I choose a mode (mode:4 - use HDMI CEC) in the configuration and it successfully controlled the monitor. What I would need is to have these commands implemented in a PIR sensor module, or I would need some guidance on how to implement these codes in the MMM-PIR-Sensor-Lite module.

      Any insight you might have would be appreciated…

      S 1 Reply Last reply Reply Quote 1
      • S Offline
        sdetweil @Freddy_boy
        last edited by sdetweil

        @Freddy_boy on the cec side

        from the raspberry pi forums
        https://forums.raspberrypi.com/viewtopic.php?t=348779

        to add to the module, edit the node_helper.js and change the command for one of the modes to use the cec commands (Once u get them to work)

        I can’t get cec to work on my pi3… works ok on my pi 4…
        (haven’t tried the latest kernel version of pi os)

        if u want to add another mode to pir-sensor-lite

        in the modulename.js change

        		if(!['vcgencmd', 'xrandr', 'xset'].includes(this.config.commandType)) {
        

        that to include whatever string you use for the cec command type

        and then in the node_helper.js

        switch(this.config.commandType) {
        				case 'vcgencmd':
        					exec("/usr/bin/vcgencmd display_power 1", null);
        					break;
        

        change the case tot the new string you picked and then change the exec command to the cec command

        note:

        there are two places to change… 1 to turn on the monitor, one to turn off, same commandType, different exec commands

        OR post an issue to the module author asking them to provide the support…

        OR make the change on your own fork of the module and submit back to the author as an enhancement.

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • F Offline
          Freddy_boy
          last edited by

          Ok. I think I understand the strategy here. I will just need to figure out the proper HDMI CEC code that I need. Thanks. I’ll let you know how things progress…

          S 1 Reply Last reply Reply Quote 1
          • S Offline
            sdetweil @Freddy_boy
            last edited by sdetweil

            @Freddy_boy you could copy it out of the ext screen module which worked… (if u still have the older repo installed somewhere)

            thats what I did when I was testing PIR and other sensors a year or so ago

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • F Offline
              Freddy_boy
              last edited by

              I attempted to run the CEC commands manually, but that doesn’t work. I just keep getting active source unknown error message. Unfortunately, I don’t have the original EXT-Screen module because I attempted to perform an update on the module, so I only have the updated module. Perhaps the updated module has updated code? But I don’t know where to look for the required commands. I’ve looked at the EXT-Screen.js file and the node_helper.js file and I don’t see anything that looks like a CEC command. Also, the files are difficult to view, as the entire code is written on a single line, so you need to search for text strings to find anything.

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @Freddy_boy
                last edited by sdetweil

                @Freddy_boy said in MMM-PIR-Sensor-Lite modification:

                Also, the files are difficult to view, as the entire code is written on a single line, so you need to search for text strings to find anything.

                yes, he has minified the code to prevent others using it… or learning form it…

                does this work to list the cec devices?

                echo 'scan' | cec-client -s -d 1
                

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • F Offline
                  Freddy_boy
                  last edited by

                  From SSH connection:

                  pi@raspberrypi:~ $ echo ‘scan’ | cec-client -s -d 1
                  opening a connection to the CEC adapter…
                  requesting CEC bus information …
                  CEC bus information

                  ===================
                  device #1: Recorder 1
                  address: 1.0.0.0
                  active source: no
                  vendor: Pulse Eight
                  osd string: CECTester
                  CEC version: 1.4
                  power status: on
                  language: eng

                  currently active source: unknown (-1)
                  pi@raspberrypi:~ $

                  1 Reply Last reply Reply Quote 0
                  • F Offline
                    Freddy_boy
                    last edited by

                    Update: I’m not sure how it happened, but I believe that my monitor had the controls disabled. It is an LG monitor using Simplink, and when I enable it, I can now see the device:

                    pi@raspberrypi:~ $ echo ‘scan’ | cec-client -s -d 1
                    opening a connection to the CEC adapter…
                    requesting CEC bus information …
                    CEC bus information

                    ===================
                    device #0: TV
                    address: 0.0.0.0
                    active source: yes
                    vendor: LG
                    osd string: TV
                    CEC version: 1.3a
                    power status: on
                    language: eng

                    device #1: Recorder 1
                    address: 1.0.0.0
                    active source: no
                    vendor: LG
                    osd string: CECTester
                    CEC version: 1.3a
                    power status: on
                    language: eng

                    currently active source: TV (0)

                    However, when I attempt to turn OFF the monitor using the CEC control commands, it doesn’t seem to work. The commands appear to be working (ie. no error messages returned), but the monitor remains ON when I issue the standby command. I also use the ‘power’ command to check the status of the monitor, and it confirms that it is ON.

                    pi@raspberrypi:~ $ echo ‘pow 0.0.0.0’ | cec-client -s -d 1
                    opening a connection to the CEC adapter…
                    power status: on
                    pi@raspberrypi:~ $ echo ‘standby 0.0.0.0’ | cec-client -s -d 1
                    opening a connection to the CEC adapter…
                    pi@raspberrypi:~ $ echo ‘pow 0.0.0.0’ | cec-client -s -d 1
                    opening a connection to the CEC adapter…
                    power status: on
                    pi@raspberrypi:~ $

                    S 1 Reply Last reply Reply Quote 0
                    • F Offline
                      Freddy_boy
                      last edited by

                      I have also tried:
                      sudo echo ‘standby 0.0.0.0’ | sudo cec-client -s -d 1

                      but got the same result…

                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @Freddy_boy
                        last edited by

                        @Freddy_boy ok, I have a CEC tv which I can turn OFF, but not back on…

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        1 Reply Last reply Reply Quote 0
                        • F Offline
                          Freddy_boy
                          last edited by

                          Yes, but this used to work previously. I suspect that none of the commands are working (even if no error message is returned). I attempted other commands, and they also do not seem to work. For example, I tried to change HDMI inputs, and the monitor remains at the same input. I think I need to determine if I can get ANY HDMI CEC command to work at all. It seems to be a missing step somewhere…

                          S 1 Reply Last reply Reply Quote 0
                          • S Offline
                            sdetweil @Freddy_boy
                            last edited by

                            @Freddy_boy I have not studied the CEC commands

                            Sam

                            How to add modules

                            learning how to use browser developers window for css changes

                            1 Reply Last reply Reply Quote 0
                            • F Offline
                              Freddy_boy
                              last edited by

                              Here is the last portion of the debug log when I attempt to issue the standby command:

                              WARNING: [ 3123] FIXME: LG seems to have bugged out. resetting to ‘in transition standby to on’. the return button will not work
                              DEBUG: [ 3123] Recorder 1 (1): power status changed from ‘on’ to ‘in transition from standby to on’
                              DEBUG: [ 3123] << Recorder 1 (1) -> TV (0): in transition from standby to on
                              TRAFFIC: [ 3123] << 10:90:02
                              DEBUG: [ 3123] >> TV (0) -> Recorder 1 (1): give device power status (8F)
                              DEBUG: [ 3175] expected response not received (90: report power status)
                              DEBUG: [ 3189] CLinuxCECAdapterCommunication::Process - ioctl CEC_RECEIVE - rx_status=01 len=2 addr=01 opcode=46
                              DEBUG: [ 3276] CLinuxCECAdapterCommunication::Write - ioctl CEC_TRANSMIT - tx_status=01 len=3 addr=10 opcode=90
                              TRAFFIC: [ 3276] << 10:8f
                              DEBUG: [ 3276] Recorder 1 (1): power status changed from ‘in transition from standby to on’ to ‘on’
                              DEBUG: [ 3366] CLinuxCECAdapterCommunication::Process - ioctl CEC_RECEIVE - rx_status=01 len=3 addr=01 opcode=89
                              DEBUG: [ 3428] CLinuxCECAdapterCommunication::Write - ioctl CEC_TRANSMIT - tx_status=01 len=2 addr=10 opcode=8f
                              TRAFFIC: [ 3429] >> 01:90:00
                              DEBUG: [ 3429] TV (0): power status changed from ‘unknown’ to ‘on’
                              DEBUG: [ 3429] expected response received (90: report power status)
                              DEBUG: [ 3429] >> TV (0) -> Recorder 1 (1): report power status (90)
                              NOTICE: [ 3429] << putting ‘TV’ (0) in standby mode
                              TRAFFIC: [ 3429] << 10:36
                              TRAFFIC: [ 3429] >> 01:1a:01
                              DEBUG: [ 3429] >> TV (0) -> Recorder 1 (1): give deck status (1A)
                              DEBUG: [ 3494] CLinuxCECAdapterCommunication::Process - ioctl CEC_RECEIVE - rx_status=01 len=2 addr=01 opcode=46
                              DEBUG: [ 3557] CLinuxCECAdapterCommunication::Write - ioctl CEC_TRANSMIT - tx_status=01 len=2 addr=10 opcode=36
                              DEBUG: [ 3557] unregistering all CEC clients
                              NOTICE: [ 3557] unregistering client: libCEC version = 6.0.2, client version = 6.0.2, firmware version = 0, logical address(es) = Recorder 1 (1) , physical address: 1.0.0.0, compiled on Linux-5.10.63-v8+ … , features: P8_USB, DRM, P8_detect, randr, RPi, Exynos, Linux, AOCEC
                              DEBUG: [ 3557] Recorder 1 (1): power status changed from ‘on’ to ‘unknown’
                              DEBUG: [ 3557] Recorder 1 (1): vendor = Unknown (000000)
                              DEBUG: [ 3557] Recorder 1 (1): CEC version unknown
                              DEBUG: [ 3557] Recorder 1 (1): osd name set to ‘Recorder 1’
                              DEBUG: [ 3557] Recorder 1 (1): device status changed into ‘unknown’
                              DEBUG: [ 3557] CLinuxCECAdapterCommunication::SetLogicalAddresses - ioctl CEC_ADAP_S_LOG_ADDRS - log_addr_mask=0000 num_log_addrs=0
                              DEBUG: [ 3557] CLinuxCECAdapterCommunication::SetLogicalAddresses - ioctl CEC_ADAP_S_LOG_ADDRS - log_addr_mask=0000 num_log_addrs=0
                              DEBUG: [ 3557] unregistering all CEC clients
                              TRAFFIC: [ 3557] >> 01:46
                              DEBUG: [ 3558] CLinuxCECAdapterCommunication::SetLogicalAddresses - ioctl CEC_ADAP_S_LOG_ADDRS - log_addr_mask=0000 num_log_addrs=0
                              TRAFFIC: [ 3558] >> 01:89:01
                              TRAFFIC: [ 3558] >> 01:46
                              DEBUG: [ 3558] CLinuxCECAdapterCommunication::Process - CEC_DQEVENT - CEC_EVENT_STATE_CHANGE - log_addr_mask=0000 phys_addr=1000
                              DEBUG: [ 3558] >> TV (0) -> Recorder 1 (1): give osd name (46)
                              DEBUG: [ 3558] >> TV (0) -> Recorder 1 (1): vendor command (89)
                              DEBUG: [ 3558] >> TV (0) -> Recorder 1 (1): give osd name (46)
                              DEBUG: [ 4564] CLinuxCECAdapterCommunication::Process - stopped - m_path=/dev/cec0 m_fd=4
                              DEBUG: [ 4564] CLinuxCECAdapterCommunication::Close - m_path=/dev/cec0 m_fd=4

                              This seems to indicate that it will not take the command, and returns the monitor to the ON state. But I don’t know where to look next…

                              S 1 Reply Last reply Reply Quote 0
                              • S Offline
                                sdetweil @Freddy_boy
                                last edited by

                                @Freddy_boy google is your friend… sort of…lol… i would search the messages…

                                Sam

                                How to add modules

                                learning how to use browser developers window for css changes

                                1 Reply Last reply Reply Quote 0
                                • F Offline
                                  Freddy_boy
                                  last edited by

                                  As I dig more into this, I am finding that there seem to be a lot of reports that some LG monitors do not support using the Standby command. I am not certain of how this was working before, but now I am beginning to suspect that the Magic Mirror app simply went hidden when the timeout occurred. Perhaps the monitor was ON all along, but the app disappeared from the screen? I don’t know if this applies in my situation, because I can’t seem to make any of the CEC commands work at all.

                                  I attempted to turn OFF the monitor, and then issue the CEC ON command, but that also did not work. It appears to be some fundamental issue with the CEC commands that I may not be able to use. Are you aware of any modules that simply blackout the Magic Mirror app using the PIR sensor? I know that isn’t really saving as much energy, but it might be worthwhile implementing…

                                  S wishmaster270W 2 Replies Last reply Reply Quote 0
                                  • S Offline
                                    sdetweil @Freddy_boy
                                    last edited by

                                    @Freddy_boy you can try my MMM-SleepWake
                                    https://github.com/sdetweil/MMM-SleepWake

                                    it listens for pir sensor or lite to signal user presence

                                    and mode HIDE will hide all the modules and show them again when a user appears

                                    I built this to use this with a webcam as I don’t have any pirs, and none of my monitors will behave (big ‘no power’ warning when hdmi goes off)

                                    I just added the code for sensor-lite, just a check …

                                    Sam

                                    How to add modules

                                    learning how to use browser developers window for css changes

                                    1 Reply Last reply Reply Quote 0
                                    • F Offline
                                      Freddy_boy
                                      last edited by

                                      I assume that I would need to re-configure the MMM-PIR-Sensor-Lite module to prevent the command from turning OFF the HDMI. How do I do that?

                                      S 1 Reply Last reply Reply Quote 0
                                      • S Offline
                                        sdetweil @Freddy_boy
                                        last edited by

                                        @Freddy_boy dang, this module also doesn’t alert other modules…

                                        too much to change quickly… sorry

                                        Sam

                                        How to add modules

                                        learning how to use browser developers window for css changes

                                        bugsounetB 1 Reply Last reply Reply Quote 0
                                        • bugsounetB Offline
                                          bugsounet Banned @sdetweil
                                          last edited by bugsounet

                                          Really…

                                          Should I recode a module by merging screen and pir plugins ??

                                          Yes, I can do it but… I not really interested to maintened it
                                          @sdetweil: if I add you to contributor, you are able to “maintened” it ?

                                          I will create MMM-Pir

                                          bugsounetB 1 Reply Last reply Reply Quote 0
                                          • wishmaster270W Offline
                                            wishmaster270 Module Developer @Freddy_boy
                                            last edited by wishmaster270

                                            @Freddy_boy
                                            Hi, my MMM-Screen-Powersave-Notification module can do this job. It has a hideInsteadShutoffoption.
                                            You need my MMM-GPIO-Notifications in addition.
                                            I wrote a Guide of how to configure the modules.

                                            1 Reply Last reply Reply Quote 1

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy